我有一个类:
public class AccountDetail
{
public DetailScope Scope
{
get { return scope; }
set { scope = value; }
}
public string Value
{
get { return this.value; }
set { this.value = value; }
}
private DetailScope scope;
private string value;
public AccountDetail(DetailScope scope, string value)
{
this.scope = scope;
this.value = value;
}
}
还有一个枚举:
public enum DetailScope
{
Private,
Business,
OtherDetail
}
最后,我有一个.xaml文件:
<Window x:Class="Gui.Wpf.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test"
SizeToContent="WidthAndHeight">
<Grid>
<ComboBox
Name="ScopeComboBox"
Width="120"
Height="23"
Margin="12" />
</Grid>
</Window>
我想做两件事:
- 我希望将
DetailsScope
枚举值与组合框的值进行数据绑定。我不想直接绑定枚举值,因为最后一个枚举值将是OtherDetail
而不是Other detail
(添加了空格字符和小写字母“d”)。 - 我希望将组合框中选择的值与
AccountDetail
对象实例中指定的值进行数据绑定。
你能帮我吗?谢谢。
更新:我找到了这篇文章:http://blogs.msdn.com/b/wpfsdk/archive/2007/02/22/displaying-enum-values-using-data-binding.aspx。我需要类似的东西。