我在网上搜索与圆角文本框,并找到一个XAML代码如下图所示:圆角文本框在WPF
<Style TargetType="{x:Type my1:CustomTextBox}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate >
<Border Background="{TemplateBinding Background}" x:Name="Bd"
BorderThickness="2" CornerRadius="5" BorderBrush="#FFF9EAB6">
***<ScrollViewer x:Name="PART_ContentHost" />***
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="#FFC7B0B0"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="#FFC7B0B0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="False">
<Setter Property="Foreground" Value="#FFC7B0B0"/>
</Trigger>
<Trigger Property="Width" Value="Auto">
<Setter Property="MinWidth" Value="120"/>
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="27"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我想了解一下什么是
<ScrollViewer x:Name="PART_ContentHost" />
详细
为什么如果从它删除此行,请不要正确地使用我的模板, 请详细告诉我。
非常感谢。
谢谢您的回答,根据您的通话,在任何控件,在那里我写“ ”的模板代码,实际控制的地方有,'x:Name ='PART_ContentHost''是指控制本身,你认为我相信吗? –
是的,基本上是的,但并非所有的控件都具有相同的部件名称。它取决于他们做什么。 http://xamlcoder.com/cs/blogs/joe/archive/2007/12/13/building-custom-template-able-wpf-controls.aspx和http://drwpf.com/blog/category上的一些示例/ control-templates/ – 2012-05-09 04:58:50
非常感谢.......... –