首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hub.Header模板

Hub.Header模板
EN

Stack Overflow用户
提问于 2014-02-26 07:44:04
回答 1查看 1.2K关注 0票数 1

我想为集线器创建模板,因为我需要复杂的StackPanel头,但我不知道如何做。首先,我想检查TextBlock控件,所以我编写了三种样例样式:

代码语言:javascript
复制
<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>

试着用这种方法:

代码语言:javascript
复制
<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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-26 07:57:56

使用HeaderTemplate为标头定义模板。

代码语言:javascript
复制
<Style x:Key="HubSectionStyle2" TargetType="HubSection">
  <Setter Property="HeaderTemplate">
    <Setter.Value>
      <DataTemplate>
        <TextBlock>With Style2</TextBlock>
      </DataTemplate>
    </Setter.Value>
  </Setter>
</Style>

获取有关HeaderTemplate的更多详细信息,您可以获得这里..。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22034922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档