I have a ListView in my MVVM WPF implementation, it has a DataTemplate with a button inside. The ListView is bound to a collection of complex objects in the 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>
All the text fields are bound with no problem, but can I bind the Button Command to a member method of the ComplexObject? If so is there any way to pass parameters?
I have a feeling I'm probably just evading using an ICommand.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…