所以我有这个object
:
public class Test : INotifyPropertyChanged
{
public string Name { get; set; }
private bool isSelected;
public bool IsSelected
{
get { return isSelected; }
set
{
isSelected = value;
NotifyPropertyChanged("IsSelected");
}
}
public Test(string name, string path, bool selected)
{
Name = name;
Path = path;
isSelected = selected;
}
public override string ToString()
{
return Name;
}
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
所以我已经ListView
绑定了我的object
( Test
) 并且当用户点击ListViewItem
我想将我的IsSelected
属性从更改true
为false
(或反之亦然......)
并且MouseLeftButtonUp
:
<ListView Name="listViewTests" ItemsSource="{Binding Tests}">
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding MouseLeftButtonUpCommand}"
CommandParameter="{Binding ElementName=listViewTests, Path=SelectedItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
我的Execute
命令:
public void Execute(object parameter)
{
Test test = parameter as Test;
if (test != null)
{
}
}
property
因此,与其在此方法中更改我的对象,Execute
我想知道如何在XAML