我正在做 :
<ListView Margin="34,42,42,25" Name="listView1">
<ListView.View>
<GridView>
<GridViewColumn Width="550" Header="Value" DisplayMemberBinding="{Binding Path=MyValue}"/>
</GridView>
</ListView.View>
<ListView.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Green"/>
</Style>
</ListView.Resources>
</ListView>
这是有效的,我可以看到我的绿色物品。
现在,我想对此使用绑定值,所以我有一个属性:
private Color _theColor;
public System.Windows.Media.Color TheColor
{
get { return _theColor; }
set
{
if (_theColor != value)
{
_theColor = value;
OnPropertyChanged("TheColor");
}
}
}
但如果我使用这个绑定:
<Setter Property="Foreground" Value="{Binding Path=TheColor}"/>
它不工作...
我该如何纠正?
当然,我将 TheColor 设置为Colors.Green
...
谢谢你的帮助