選択した値が変更されるたびに個別のコマンドをトリガーする単純な ComboBox があります。これが私のマークアップの例です:
<WrapPanel Grid.Row="0" Visibility="{Binding ShowToggleViewFeedViewManual}">
<ComboBox Margin="3,3,0,0">
<ComboBoxItem IsEnabled="{Binding CanSelectViewFeedData}" >
<ComboBoxItem.CommandBindings>
<CommandBinding Command="SelectViewFeedDataCommand" />
</ComboBoxItem.CommandBindings>
<TextBlock Text="View Feed Data"/>
</ComboBoxItem>
<ComboBoxItem IsEnabled="{Binding CanSelectViewManualData}">
<ComboBoxItem.CommandBindings>
<CommandBinding Command="SelectManualFeedDataCommand" />
</ComboBoxItem.CommandBindings>
<TextBlock Text="View Manual Data"/>
</ComboBoxItem>
</ComboBox>
</WrapPanel>
「'SelectViewFeedDataCommand' を変換できません」というエラーが表示されます。他の ComboBoxItem でも同様のエラーが発生します。ICommand は、DataTemplate としてバインドされた UserControl の DataSource である ViewModel クラスで定義されます。
public ICommand SelectViewFeedDataCommand
{
get
{
// Code to perform
}
}
私はこれをかなり広範囲に調査しましたが、ICommand を ComboBoxItem に効果的にバインドする方法についての答えは見つかりませんでした。
一連のラジオボタンと関連するコマンドを使用する既存のコードからこれを適応させていますが、これは非常に簡単に実行できます。ComboBox でこれを行う簡単な方法はありませんか?
ありがとう。