次のように xaml でコンボボックスを作成しました。
ComboBox x:Name="cbTest" ItemsSource="{Binding}" SelectedValue="{Binding Test, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,10,0,0" Width="250" SelectionChanged="cbTest_SelectionChanged"/>
Combobox には次の ItemSource が含まれています。
cbTest.ItemsSource = new string[] { "Left", "Right", "Center" };
Combobox に 3 つの文字列が表示されますが、以前に選択した SelectedValue が表示されません。これはプロパティです:
private short _test;
public short Test
{
get
{
return _test;
}
set
{
_test = value;
NotifyPropertyChanged();
}
}
テストでは、次のデータが得られます:「左」。それで、データを取得しましたが、バインディングが機能していません!
ありがとう!