私は簡単な辞書を持っています。i をコンボボックスにバインドしてから、選択した値を別のプロパティにバインドしたいと思います。
private const string CellListPropertyName = "CellList";
private Dictionary<string, string> _cellList;
public Dictionary<string, string> CellsList
{
get { return _cellList; }
set
{
_cellList = value;
RaisePropertyChanged(CellListPropertyName);
}
}
これが私のコードです:
<ComboBox x:Name="comboBox"
ItemsSource="{Binding CellsList}"
DisplayMemberPath="Value"
SelectedValuePath="Key"
SelectedValue="{Binding Path=Conf:ConfProperties.Title}">
私はさまざまな方法を試しましたが、コンボボックスは常に空です(ItemTemplatesなどを使用しても)、62個の要素が含まれている辞書を確認しました。
また、「SelectedValue」を DataContext で定義されたプロパティにバインドしようとしましたが、まだ機能しません。
これが私のコンテキストです
<UserControl.DataContext>
<viewModel:ParametersViewModel></viewModel:ParametersViewModel>
</UserControl.DataContext>