绑定和样式不适用于 Win8?
我从一个 TextBox 派生出来,并称它为 MyTextBox.在我的 LayoutAwarePage 上,我创建了 2 个 SolidColorBrush 道具:MyBackground 和 MyBorder.在该页面的 Xaml 中,我为控件 MyTextBox 编写了一个带有样式的 ResourceDictionary:
I derived from a TextBox and called it MyTextBox. On my LayoutAwarePage I created 2 SolidColorBrush props: MyBackground and MyBorder. In the Xaml of that page I wrote a ResourceDictionary with style to the control MyTextBox:
<Grid.Resources>
<ResourceDictionary>
<Style TargetType="a:MyTextBox">
<Setter Property="Background" Value="{Binding MyBackground}"></Setter>
<Setter Property="BorderBrush" Value="{Binding MyBorder}"></Setter>
<Setter Property="Width" Value="200"></Setter>
<Setter Property="IsReadOnly" Value="False"></Setter>
<Setter Property="BorderBrush" Value="3"></Setter>
</Style>
</ResourceDictionary>
</Grid.Resources>
当我运行这个页面时,我看不到控件.我没有忘记为页面创建一个DataContext,并且属性是真彩色(不是黑色).知道如何解决这个问题吗?
When I run this page I can't see the control. I didn't forget to create a DataContext for the page, and the properties are true colors (not black). Any idea how to solve this?
WinRT 不支持样式设置器中的绑定.
Binding in Style Setters is not supported in WinRT.