【问题标题】:Best way to put a border around ListView items在 ListView 项目周围放置边框的最佳方法
【发布时间】:2014-06-12 20:11:02
【问题描述】:

我有一个 ListView,我想在 ListView 中的每个项目周围放置一个边框。 Microsoft 似乎没有 Border 元素的系统主题。

推荐的边框主题方法是什么,使其在深色和浅色主题上看起来不错?

这是我的列表视图

<ListView ItemsSource="{Binding Products}" Header="My Header" Margin="10,5,10,5">
                    <ListView.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="My Header" Style="{ThemeResource HeaderTextBlockStyle}" />
                        </DataTemplate>
                    </ListView.HeaderTemplate>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Border>
                                <StackPanel>
                                    <TextBlock Text="{Binding Name}"
                                               Style="{StaticResource TitleTextBlockStyle}" />
                                    <TextBlock Text="TextBlock 1:"
                                               Style="{StaticResource ControlHeaderTextBlockStyle}" />
                                    <TextBox Text="{Binding TextBlock1}"/>
                                    <TextBlock Text=" TextBlock 2:"
                                               Style="{ThemeResource ControlHeaderTextBlockStyle}"/>
                                    <TextBox Text="{Binding TextBlock2}"/>
                                </StackPanel>

                            </Border>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

******************编辑 1******************

我应该放这个。我希望它在针对 WP8.1 和 Windows 8.1 的通用应用程序中,而不仅仅是手机。

【问题讨论】:

    标签: xaml windows-runtime windows-phone windows-phone-8.1


    【解决方案1】:

    您可能只想要标准的前景色,对吧? (黑暗代表光明,光明代表黑暗)。那就是PhoneContrastForegroundBrush

    <Border BorderThickness="1" BorderBrush="{StaticResource PhoneContrastForegroundBrush}">
    

    【讨论】:

    • +1 我更喜欢 contrastforegroundbrush,忘记了那个,事实上我想我只会删除我的答案,因为它超出了所需的范围。 :)
    • PhoneContrastForegroundBrush 在 Windows Phone 8.1 中找不到,只有 Windows Phone Silverlight 8.1。
    【解决方案2】:

    前面的答案引导我查看系统画笔,我发现了 ApplicationForegroundThemeBrush,我相信它会起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-23
      • 1970-01-01
      • 1970-01-01
      • 2022-11-04
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      • 1970-01-01
      相关资源
      最近更新 更多