I am working with WPF and trying to change the Enabled state of a button when we selected an Item of a ListView, or in other words, how to trigger the Enabled state of a button when we Select any ListViewItem?
And i am trying to do the reverse thing with another button, or in other words… Can i change the SelectedItem property from the ListView to null when i click in other button if i am using Commands? How?
Thanks in advance!
You could use a
DataTriggerto disable it when null.e.g. (
ListViewbeing namedlv)Alternatively you could bind the
IsEnabledproperty directly and add aConverterto the binding which returns a respective bool.Example to clear selection: