我想为集线器创建模板,因为我需要复杂的StackPanel头,但我不知道如何做。首先,我想检查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>试着用这种方法:
<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>因此,我有四列,标题如下:
没有风格,有Style1,Windows.UI.Xaml.DataTemplate,Windows.UI.Xaml.ControlTemplate
发布于 2014-02-26 07:57:56
使用HeaderTemplate为标头定义模板。
<Style x:Key="HubSectionStyle2" TargetType="HubSection">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock>With Style2</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>获取有关HeaderTemplate的更多详细信息,您可以获得这里..。
https://stackoverflow.com/questions/22034922
复制相似问题