WPF 데이터 바인딩 : XAML을 사용하여 열거 형을 콤보 상자에 바인딩하는 방법은 무엇입니까?
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;
}
}
및 enum :
마지막으로 xxx 파일이 있습니다.<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
열거 형 값을 콤보 상자 값에 데이터 바인딩합니다. 마지막 열거 형 값이Other detail
대신 공백 문자와 작은 문자 'd'대신OtherDetail
가 될 것이기 때문에 가 열거 형 값을 직접 바인드하기를 원하지 않습니다.- 콤보 상자에서 선택된 값을
AccountDetail
객체의 인스턴스에 지정된 값으로 데이터 바인딩하려고합니다.
나 좀 도와 줄래? 감사.
업데이트 :이 게시물 http://blogs.msdn.com/b/wpfsdk/archive/2007/02/22/displaying-enum-values-using-data-binding.aspx를 발견했습니다. 나는 비슷한 것을 필요로한다.
끝내 주네! 고마워, Meleak – Boris