如何获取 xaml 中样式设置器属性的值?
例如,我有下一个样式:
<Style TargetType="TextBox">
<Setter Property="Background" Value="YellowGreen" />
</Style>
如何从 TextBox 默认样式中获取背景属性的值?
<Style TargetType="Button">
<Setter Property="Background" Value="{Binding ???}" />
</Style>
我需要这个因为我无法访问TextBox
style..
如果您无法修改 TextBox 样式,您可以执行此解决方法(经过测试,有效):
<TextBox x:Key="DefaultTextBox" />
<Style TargetType="Button">
<Setter Property="Background"
Value="{Binding Source={StaticResource DefaultTextBox}, Path=Background}" />
</Style>
您无法在 xaml 中绑定到背景样式的 setter。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)