WPF,请问BorderThickness属性

fgfgf5 2013-07-20 04:23:12
在标准的ScrollBar模板中,看到一段关于RepeatButton的样式,实在看不懂,帮忙解释一下:

<RepeatButton...>
<RepeatButton.Style>
...
...
<Setter Property="Border.BorderThickness">
<Setter.Value>
<Thickness>1,1,1,1</Thickness>
</Setter.Value>
</Setter>

...
...
</RepeatButton….>

代码中,红色部分设置了BorderThickness属性,可是为什么是写的:Border.BorderThickness呢?
难道此地方设置的不是RepeatButton的BorderThickness属性吗?
...全文
3184 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
铜板 2014-07-30
  • 打赏
  • 举报
回复
这是因为是为RepeatButton.Border.BorderThickness设置样式!
申江渔夫 2013-07-22
  • 打赏
  • 举报
回复
你代码没贴全,RepeatButton中应该用到Border的。
fgfgf5 2013-07-22
  • 打赏
  • 举报
回复
引用 8 楼 guwei4037 的回复:
Border.BorderThickness设置为1,1,1,1,比如如果是绑定到button的样式的话,就是button的左、上、右、下4个边框的宽度。
4个边框的宽度不是用BorderThickness表示的吗?为什么是Border.BorderThickness
全栈极简 2013-07-22
  • 打赏
  • 举报
回复
Border.BorderThickness设置为1,1,1,1,比如如果是绑定到button的样式的话,就是button的左、上、右、下4个边框的宽度。
fgfgf5 2013-07-22
  • 打赏
  • 举报
回复
RepeatButton的边框宽度设置为了3,那Border.BorderThickness设置为1,1,1,1,这是设置的什么东西?不会又是边框宽度吧
fgfgf5 2013-07-22
  • 打赏
  • 举报
回复
有人知道吗???
fgfgf5 2013-07-22
  • 打赏
  • 举报
回复
标准的RepeatButton模板如下: <RepeatButton Command="ScrollBar.LineUpCommand" Name="PART_LineUpButton" IsEnabled="{TemplateBinding UIElement.IsMouseOver}"> <RepeatButton.Style> <Style TargetType="RepeatButton"> <Style.Resources> <ResourceDictionary /> </Style.Resources> <Setter Property="FrameworkElement.FocusVisualStyle"> <Setter.Value> <Style TargetType="IFrameworkInputElement"> <Style.Resources> <ResourceDictionary /> </Style.Resources> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2" Margin="2,2,2,2" SnapsToDevicePixels="True" /> </ControlTemplate> </Setter.Value> </Setter> </Style> </Setter.Value> </Setter> <Setter Property="Border.BorderThickness"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> <Setter Property="Control.HorizontalContentAlignment"> <Setter.Value> <x:Static Member="HorizontalAlignment.Center" /> </Setter.Value> </Setter> <Setter Property="Control.VerticalContentAlignment"> <Setter.Value> <x:Static Member="VerticalAlignment.Center" /> </Setter.Value> </Setter> <Setter Property="Control.Padding"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> <Setter Property="UIElement.Focusable"> <Setter.Value> <s:Boolean>False</s:Boolean> </Setter.Value> </Setter> <Setter Property="KeyboardNavigation.IsTabStop"> <Setter.Value> <s:Boolean>False</s:Boolean> </Setter.Value> </Setter> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="RepeatButton"> <Border BorderThickness="1,1,1,1" BorderBrush="#FFF0F0F0" Background="#FFF0F0F0" Name="border" SnapsToDevicePixels="True"> <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" Name="contentPresenter" Margin="{TemplateBinding Control.Padding}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" Focusable="False" /> </Border> <ControlTemplate.Triggers> <Trigger Property="UIElement.IsMouseOver"> <Setter Property="Panel.Background" TargetName="border"> <Setter.Value> <SolidColorBrush>#FFDADADA</SolidColorBrush> </Setter.Value> </Setter> <Setter Property="Border.BorderBrush" TargetName="border"> <Setter.Value> <SolidColorBrush>#FFDADADA</SolidColorBrush> </Setter.Value> </Setter> <Trigger.Value> <s:Boolean>True</s:Boolean> </Trigger.Value> </Trigger> <Trigger Property="ButtonBase.IsPressed"> <Setter Property="Panel.Background" TargetName="border"> <Setter.Value> <SolidColorBrush>#FF606060</SolidColorBrush> </Setter.Value> </Setter> <Setter Property="Border.BorderBrush" TargetName="border"> <Setter.Value> <SolidColorBrush>#FF606060</SolidColorBrush> </Setter.Value> </Setter> <Trigger.Value> <s:Boolean>True</s:Boolean> </Trigger.Value> </Trigger> <Trigger Property="UIElement.IsEnabled"> <Setter Property="UIElement.Opacity" TargetName="contentPresenter"> <Setter.Value> <s:Double>0.56</s:Double> </Setter.Value> </Setter> <Setter Property="Panel.Background" TargetName="border"> <Setter.Value> <SolidColorBrush>#FFF0F0F0</SolidColorBrush> </Setter.Value> </Setter> <Setter Property="Border.BorderBrush" TargetName="border"> <Setter.Value> <SolidColorBrush>#FFF0F0F0</SolidColorBrush> </Setter.Value> </Setter> <Trigger.Value> <s:Boolean>False</s:Boolean> </Trigger.Value> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </RepeatButton.Style> <Path Data="M0,4C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4z" Stretch="Uniform" Fill="#FF606060" Name="ArrowTop" Margin="3,4,3,3" /> </RepeatButton> [/code]
fgfgf5 2013-07-21
  • 打赏
  • 举报
回复
引用 1 楼 guwei4037 的回复:
<RepeatButton BorderThickness="3"> <Setter Property="Border.BorderThickness"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> </RepeatButton> 这里的Border.BorderThickness跟RepeatButton BorderThickness的BorderThickness,不是一回事。BorderThickness是BorderThickness的属性,边框厚度。而Border.BorderThickness是引用的资源字典里的属性。 比如: <Style x:Key="CircleButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Border.BorderThickness" Value="1,1,1,1" /> </Style>
RepeatButton的边框宽度设置为了3,那Border.BorderThickness设置为1,1,1,1,这是设置的什么东西?不会又是边框宽度吧
fgfgf5 2013-07-20
  • 打赏
  • 举报
回复
引用 3 楼 flashposition 的回复:
BorderThickness是线型,实线,虚线,点划线等等
那1楼的代码: <RepeatButton BorderThickness="3"> <Setter Property="Border.BorderThickness"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> </RepeatButton> RepeatButton的边框宽度设置为了3,那Border.BorderThickness设置为1,1,1,1,这是设置的什么东西?不会又是边框宽度吧
flashposition 2013-07-20
  • 打赏
  • 举报
回复
BorderThickness是线型,实线,虚线,点划线等等
fgfgf5 2013-07-20
  • 打赏
  • 举报
回复
引用 1 楼 guwei4037 的回复:
<RepeatButton BorderThickness="3"> <Setter Property="Border.BorderThickness"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> </RepeatButton> 这里的Border.BorderThickness跟RepeatButton BorderThickness的BorderThickness,不是一回事。BorderThickness是BorderThickness的属性,边框厚度。而Border.BorderThickness是引用的资源字典里的属性。 比如: <Style x:Key="CircleButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Border.BorderThickness" Value="1,1,1,1" /> </Style>
Border.BorderThickness是引用的资源字典里的属性? Button的样式,设置Border.BorderThickness属性?还是看不懂诶 ,Border.BorderThickness指的是什么?
全栈极简 2013-07-20
  • 打赏
  • 举报
回复
<RepeatButton BorderThickness="3"> <Setter Property="Border.BorderThickness"> <Setter.Value> <Thickness>1,1,1,1</Thickness> </Setter.Value> </Setter> </RepeatButton> 这里的Border.BorderThickness跟RepeatButton BorderThickness的BorderThickness,不是一回事。BorderThickness是BorderThickness的属性,边框厚度。而Border.BorderThickness是引用的资源字典里的属性。 比如: <Style x:Key="CircleButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Border.BorderThickness" Value="1,1,1,1" /> </Style>

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧