I have a list view item which has a button and displays properties on an object. I have the command property set up for the button using the mvvm pattern which fires correctly.
My issues is that when a press the button it does not also get the selected item, I am guessing that it has not fired the selectedItem event.
Is it possible to force this event when the button is pressed?
<Button
Height="20"
Width="20"
Grid.Column="3"
Grid.Row="0"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.RemoveClick}"
CommandParameter="{Binding SelectedItem, ElementName=serverListView, Mode=TwoWay}">
您可以:-将命令的commandParameter设置为{Binding}-将SelectedItem绑定到VM的某些属性-在命令执行方法开始时将此属性设置为command参数
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.