이 NameList의 ItemsSource 인 값의 유한 집합입니까? 같은 것을 가지고, 이것에 대한 당신의 ViewModel에서 다음
<ComboBox x:Name="SampleComboBox" Width="100" SelectedItem="{Binding TheItem}" ItemsSource="{Binding Path=NameList}" />
과 :
왜 읽고 그 XAML을 수정하지
public static readonly DependencyProperty TheItemProperty=
DependencyProperty.Register("TheItem", typeof(string), typeof(OrderEditorViewModel),
new PropertyMetadata((s, e) => {
switch (e.NewValue) {
case "SomeValue":
// Do something
break;
case "SomeOtherValue":
// Do another thing
break;
default:
// Some default action
break;
}
}));
public string TheItem{
get { return (string)GetValue(TheItemProperty); }
set { SetValue(TheItemProperty, value); }
}
을 할 수 있습니다 않는 스위치의 선택에 따라 행동 선택이 변경 될 때마다 호출되는 명령문.