【问题标题】:How to change the alignment on the listview header如何更改列表视图标题的对齐方式
【发布时间】:2012-10-20 14:38:51
【问题描述】:

我正在开发一个现代的 C#/XAML Win8 应用程序。我有一个本质上是一个大列表视图的页面,其标题是图像。这非常有效,并提供了我正在寻找的所需用户体验。

一个问题,我想将图像和列表视图的其余部分居中到页面的中心。

我设法以这种方式将列表视图项居中:

<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
    </Style>
</ListView.ItemContainerStyle>

我无法弄清楚如何设置标题的样式。这是显示标题的代码:

<!-- The header of the listview is the image -->
<ListView.HeaderTemplate>
    <DataTemplate>
        <Viewbox MaxHeight="480" Width="660">
            <Image 
                x:Name="image"
                Source="{Binding ImageBig}"/>
        </Viewbox>
    </DataTemplate>
</ListView.HeaderTemplate>

有谁知道我如何做到这一点?

非常感谢您的帮助!

【问题讨论】:

    标签: c# xaml listview windows-8 microsoft-metro


    【解决方案1】:

    如果我没记错,您可以将列表视图 Horizo​​ntalAlignment 和 VerticalAlignment 设置为 Center,对于您的图像,您可以尝试将 Viewbox 的 Horizo​​ntalContentAlignment 和 VerticalContentAlignment 设置为 Center,因此如果它不起作用,请尝试使用网格。您应该能够在属性选项卡中找到它,否则您也可以在代码后面或 xaml 本身上对其进行编码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      • 2011-06-25
      • 2021-06-24
      • 1970-01-01
      • 2014-05-19
      • 2016-07-17
      • 1970-01-01
      相关资源
      最近更新 更多