“ListViewItemPlaceholderBackgroundThemeBrush”位于何处?

时间:2012-06-11 10:36:37

标签: c# xaml microsoft-metro resourcedictionary .net-4.5

我在了解Windows 8 metro应用程序中的一个样式定义时遇到问题。

使用VS创建metro风格应用程序时,还有一个名为

的文件夹
  

通用

创建。在此文件夹中有一个名为

的文件
  

StandardStyles.xaml

现在,以下代码段来自此文件:

<!-- Grid-appropriate 250 pixel square item template as seen in the GroupedItemsPage and ItemsPage -->
<DataTemplate x:Key="Standard250x250ItemTemplate">
    <Grid HorizontalAlignment="Left" Width="250" Height="250">
        <Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
            <Image Source="{Binding Image}" Stretch="UniformToFill"/>
        </Border>
        <StackPanel VerticalAlignment="Bottom" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
            <TextBlock Text="{Binding Title}" Foreground="{StaticResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource TitleTextStyle}" Height="60" Margin="15,0,15,0"/>
            <TextBlock Text="{Binding Subtitle}" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="15,0,15,10"/>
        </StackPanel>
    </Grid>
</DataTemplate>

我在这里不明白的是静态资源定义,例如为边界

Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}"

这与您使用模板,绑定和资源的方式无关。

ListViewItemPlaceholderBackgroundThemeBrush 位于何处?

非常感谢你的帮助。

低糜

2 个答案:

答案 0 :(得分:7)

在Windows 8客户预览中,您可以在以下位置找到包含资源定义的文件(包括ListViewItemPlaceholderBackgroundThemeBrush):

C:\ Program Files(x86)\ Windows Kits \ 8.0 \ Include \ winrt \ xaml \ design \ themeresources.xaml

答案 1 :(得分:5)

这是微软文档中应该出现的令人难以置信的令人沮丧的事情之一,但还不是(还)。

ListViewItemPlaceholderBackgroundThemeBrush是系统画笔资源之一。它由Metro“Light”或“Dark”主题定义(无论您选择哪种应用)。

您可以在Blend中查看系统画笔的完整列表。 (不幸的是,我还没有找到任何方法在代码中枚举它们。似乎没有任何编程方式来检查主题资源。)

以下是一些可以让您进入完整列表的步骤。 (当然,如果您已熟悉Blend,则可以缩写步骤。)

  1. 打开Expression Blend。
  2. 创建一个新项目,然后选择XAML(Windows Metro风格)&gt;空白应用程序(XAML)并单击“确定”。
  3. 单击设计图面以选择网格。 (在左下角的“对象和时间轴”停靠窗口中,“[网格]”行将突出显示。)
  4. 在右上角的属性停靠窗口中,找到“画笔”类别。
  5. 在“背景:无刷”的正下方,有一排五个按钮。单击最右侧的按钮(“刷子资源”)。
  6. 系统画笔资源列表将显示在列表框中。

    enter image description here

相关问题