如何在样式中为WinRT自定义TextBox的Header属性。
我想改变Header的FontSize& ForeGround属性在一个风格内。
我试过了:
<Style x:Name="valueTextBoxPortraitStyle" TargetType="TextBox" BasedOn="{StaticResource valueTextBoxStyle}">
<Setter Property="BorderThickness" Value="6"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Margin" Value="0,0,0,10"/>
<Setter Property="Header">
<Setter.Value>
<HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="10" Foreground="Green"/>
</DataTemplate>
</HeaderTemplate>
</Setter.Value>
</Setter>
</Style>
但它给出了错误。
答案 0 :(得分:0)
将HeaderTemplate添加为属性&amp;它解决了这个问题。
<Style x:Name="valueTextBoxPortraitStyle" TargetType="TextBox" BasedOn="{StaticResource valueTextBoxStyle}">
<Setter Property="BorderThickness" Value="6"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Margin" Value="0,10,0,0"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="14" FontWeight="Bold" Foreground="Purple"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>