【发布时间】:2013-03-19 09:35:39
【问题描述】:
我目前正在尝试将某种颜色主题功能添加到我正在使用的 Win8 应用程序中......我已经从 vm 进行绑定,并且一切都适用于静态 UI 元素。但是,我将一些注释(我的模型)添加到数据库中,它们也出现在屏幕上的 GridView 中。
但是在为 GridView ItemTemplate 声明的 DataTemplate 中,颜色绑定根本不起作用……
我的模板如下所示:
<Grid Grid.Row="3" HorizontalAlignment="Left" Width="200" Height="200">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="60"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="Lavender" Opacity="50"/>
<ScrollViewer Grid.Row="0">
<TextBlock Grid.Row="0" Text="{Binding Content}" Foreground="DodgerBlue" />
</ScrollViewer>
<Border Grid.Row="1" Background="DodgerBlue" Opacity="70"/>
<ScrollViewer Grid.Row="1">
<TextBlock Grid.Row="1" Text="{Binding Subject}" Foreground="LightBlue" />
</ScrollViewer>
<Border Grid.Row="2" Background="DodgerBlue" Opacity="70"/>
<TextBlock Grid.Row="2" Text="{Binding Importance}" Foreground="Black" FontSize="{StaticResource ComboBoxArrowThemeFontSize}" />
</Grid>
我尝试的只是将Foreground="DodgerBlue" 改为Foreground="{Binding ColorTheme}",但没有效果,SolidColorBrush 不是从 vm 获取的......
有什么解决方法吗?
非常感谢。
【问题讨论】:
-
ColorTheme 属性的类型是什么?
-
调试时输出窗口是否有任何错误?
-
ColorTheme 是 SolidColorBrush 类型。没有发现错误,只是绑定似乎不起作用,显示白色文本...
标签: xaml binding windows-8 colors windows-runtime