Jak*_*ruk 1 wpf xaml windows-8.1
我想为Hub创建模板,因为我需要StackPanel在Header中复杂,但我无法弄清楚如何做到这一点.首先,我想检查TextBlock控件,所以我写了三个样本样式:
<Style x:Key="HubSectionStyle" TargetType="HubSection">
<Setter Property="Header" Value="With Style1">
</Setter>
</Style>
<Style x:Key="HubSectionStyle2" TargetType="HubSection">
<Setter Property="Header">
<Setter.Value>
<DataTemplate>
<TextBlock>With Style2</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HubSectionStyle3" TargetType="HubSection">
<Setter Property="Header">
<Setter.Value>
<ControlTemplate>
<TextBlock>With Style3</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
并尝试这种方式:
<HubSection>
<HubSection.Header>
<TextBlock>Without Style</TextBlock>
</HubSection.Header>
</HubSection>
<HubSection Style="{StaticResource HubSectionStyle}">
</HubSection>
<HubSection Style="{StaticResource HubSectionStyle2}">
</HubSection>
<HubSection Style="{StaticResource HubSectionStyle3}">
</HubSection>
Run Code Online (Sandbox Code Playgroud)
因此,我有四列包含以下标题:
没有Style,有Style1,Windows.UI.Xaml.DataTemplate,Windows.UI.Xaml.ControlTemplate
使用HeaderTemplate定义模板头..
<Style x:Key="HubSectionStyle2" TargetType="HubSection">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>With Style2</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
获取更多关于HeaderTemplate你的详细信息可以到这里..
| 归档时间: |
|
| 查看次数: |
1221 次 |
| 最近记录: |