私はMVVM WPF実装でListViewを持っていますが、内部にボタン付きのDataTemplateがあります。 ListViewは、ViewModelの複雑なオブジェクトのコレクションにバインドされています。ボタンコマンドをメンバーメソッドにどのようにバインドしますか?
<ListView ItemsSource="{Binding Path=ComplexObjects}"
SelectedItem="{Binding Path=SelectedObject}"
Width="Auto">
<ListView.View>
<GridView>
<GridViewColumn Header="My Property">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="6,2,6,2">
<TextBlock Text="{Binding MyProperty}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="First Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="6,2,6,2">
<Button Command="{Binding ???}"/>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
すべてのテキストフィールドには問題なくバインドされているが、私はComplexObjectのメンバーメソッドにボタンコマンドをバインドすることができますか?もしそうなら、パラメータを渡す方法はありますか?
私は恐らくICommandを使用して回避していると感じています。
ありがとうございました。
@DJ KRAZE - 私はそれが役立つだろうかわからない - 私はにバインドするために探しています複雑なオブジェクトではなく、コードの背後にある。 – trickdev
ここに役立つかもしれない何か私は正しく理解していますので、本当にBindingをサポートしていないので、このサイトはhttp://connect.microsoft.com/VisualStudio/feedback/details/472932/wpf-commandparameter- binding-should-be-evaluate-before-コマンドバインディング|ここにStackOverFlowの同様のポストがあります。これは3つのオプションも提供します。http://connect.microsoft。com/VisualStudio/feedback/details/472932/wpf-command-parameter-binding-should-be-be-be-before-command-binding- – MethodMan
@DJ KRAZEありがとうございます。 – trickdev