编辑 TextBox 的 Header 属性 inside Style
Edit TextBox's Header property inside Style
如何自定义 TextBox 的 Header 属性 inside Styles for WinRT。
我想更改 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>
但是报错
添加 HeaderTemplate 作为 属性 & 它解决了问题。
<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>
如何自定义 TextBox 的 Header 属性 inside Styles for WinRT。
我想更改 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>
但是报错
添加 HeaderTemplate 作为 属性 & 它解决了问题。
<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>