【发布时间】:2010-03-03 12:46:40
【问题描述】:
好吧,伙计们,
我有一个严重的问题。
我有一个带有静态属性的静态类,提供一些颜色作为十六进制字符串:
namespace com.myCom.Views
{
public static class MyColorTable
{
private const string _Hex0 = "#FFFFFFFF";
private const string _Hex1 = "#FFE5E5E5";
public static String Hex0
{
get { return _Hex0; }
}
public static String Hex1
{
get { return _Hex1; }
}
}
}
现在,我想通过 XAML 将这些颜色绑定到 UserControl,如下所示:
<UserControl x:Class="com.testing.MyTestClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="53" Width="800"
FocusVisualStyle="{x:Null}">
<Grid x:Name="MyGrid"
Focusable="false"
FocusManager.IsFocusScope="True"
Background="{Binding Soure={x:Static MyColorTable}, Path=Hex1}"
Margin="0,0,0,0"
FocusVisualStyle="{x:Null}"
/>>
我知道这行不通,所以我的问题是,我怎么做对了?我不需要双向绑定或任何 PropertyChanged 事件,因为一旦应用启动,颜色就不会更新。
【问题讨论】: