【问题标题】:Remove Pivot's header & title删除 Pivot 的标题和标题
【发布时间】:2013-10-29 20:52:48
【问题描述】:

我正在制作一个 Windows Phone 8 C#/XAML 应用程序,我将在其中使用 Pivots

我需要将 Pivot 标头替换为允许我在枢轴之间切换的其他内容 - 如下所示:

 ____________________________
 |                          |
 |           O O            |
 |                          |
 |    ...pivot content...   |
 |       ........           |

(两个“O”符号是单选按钮或类似的东西,而不是枢轴标题,我希望它们在整个页面被查看期间都保持可见)

现在,我认为解决它并使它看起来像这样的最佳方法是隐藏/删除数据透视和数据透视项的标题并放置“单选按钮”。

如何在 windows phone 8 上实现它(最好通过 XAML 中的样式,我需要多个看起来像这样的数据透视控件 - 在多个页面上)?

 //this is pseudocode based on XAML just to show the structure I'm thinking about
 <grid>
   <radiobuttongroup>
       <radiobutton />  //"radiobuttons" for moving between pivot items
       <radiobutton />
       ...
   </radiobuttongroup>
   <pivot>
     <pivotitem />   //the actual pivot items with content
     <pivotitem />
     ....
   </pivot>
 </grid>

我一直在搜索,但找不到任何可以为我“敲响警钟”的内容。

【问题讨论】:

    标签: c# xaml windows-phone-8


    【解决方案1】:

    您需要修改数据透视控件的标题模板。我在我的代码中这样做了:

     <phone:Pivot Title="">
          <phone:Pivot.HeaderTemplate>
           <DataTemplate>
             <Grid Margin="0 -12 0 0"  Height="auto">
              <TextBlock Padding="0" Height="auto" Margin="0" Text="{Binding}"/>
             </Grid>
           </DataTemplate>
          </phone:Pivot.HeaderTemplate>
            <phone:Pivot.ItemTemplate>
             <DataTemplate>
              <Grid Margin="0"/>
             </DataTemplate>
          </phone:Pivot.ItemTemplate>
          <phone:PivotItem Header="" Height="100" Margin="162,0,218,116">
            <Grid/>
          </phone:PivotItem>
        </phone:Pivot>
    

    【讨论】:

    • 在我的通用应用程序中不起作用。虽然似乎是一个很好的解决方案/黑客
    • 只需将 Visibility="Collapsed" 属性添加到 标记 - 它应该可以解决问题。此外,这样 Text 属性变得多余(因为我们不显示任何内容)
    【解决方案2】:

    也许看看我的示例,了解如何在 Windows 手机上模仿当前的 twitter 应用程序http://depblog.weblogs.us/2013/08/29/twitterate-your-windows-phone-app/

    它与您要查找的内容不完全相同,但它包含有关如何设置没有标题的枢轴并通过另一个 UI 项处理枢轴更改的 xaml 代码。

    我希望这会有所帮助...

    【讨论】:

    • 这正是我正在寻找的。 :)
    猜你喜欢
    • 1970-01-01
    • 2021-12-25
    • 1970-01-01
    • 2015-04-28
    • 2020-04-18
    • 1970-01-01
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    相关资源
    最近更新 更多