【发布时间】:2018-09-14 20:12:39
【问题描述】:
我的 xaml 文件中有一个来自第三方库的元素
<core:CheckBox />
它在那个库中有它自己的风格
<Style x:Key="{x:Type controls:CheckBox}" TargetType="{x:Type controls:CheckBox}">
<Style.Setters>
<Setter Property="FrameworkElement.Width" Value="170" />
<Setter Property="FrameworkElement.Height" Value="60" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:CheckBox}">
<controls:Button x:Name="Button"
Width="{TemplateBinding FrameworkElement.Width}"
Height="{TemplateBinding FrameworkElement.Height}"
...
</ControlTemplate>
</Setter.Value>
</Setter>
...
</Style>
不幸的是,由于设置了高度和宽度,它不想拉伸。
我无法修改第三方库中的样式。情况有其优点,因为如果他们改变样式,我的元素将与系统的其他部分具有统一的外观。
我想使用样式,但不知何故放弃了高度和宽度设置器。 有什么想法吗?
编辑: CheckBox 在 Grid 中,它不会填充单元格,这就是目标。
【问题讨论】:
标签: .net wpf dependency-properties wpf-style