使用样式想象我有一个数据绑定ListView和在<ControlTemplate.Triggers>
Windows Presentation Foundation中
我有以下
<DataTrigger Binding="{Binding Path=Status}" Value="Completed">
<Setter Property="Background" Value="{StaticResource CompletedBackground}" />
<Setter Property="Foreground" Value="Black" />
</DataTrigger>
我想要绑定到一个风格,我有我的网格。资源,如下所示:
<Style x:Key="CompletedBackground" TargetType="ListViewItem">
<Setter>
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFBCFAA6" Offset="0"/>
<GradientStop Color="#FFA3E88B" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
然而,正如你可以想像这是不行的,惊喜惊喜,你不能绑定“二传手”到“背景”,所以我questio ñ是,我怎么才能真正解决问题?
我看了下面很多次,找不到任何信息here。
您是否尝试使用DynamicResource而不是StaticResource? – japf 2009-09-28 12:09:59