You need to click on the ListView item ListView get the item itself. You need to use only ItemClick , not SelectedItem and so on. After clicking on the list item, the OnClick method is OnClick

  private void OnClick(object sender, RoutedEventArgs e){} 

In "e" I found the value I need The value of the argument "e"

Garter events

 protected override void OnAttached() { this.AssociatedObject.ItemClick += OnClick; this.AssociatedObject.IsItemClickEnabled = true; } 

The question is to get it, how can it be done?

e.ClickedItem does not find enter image description here

  • msdn.microsoft.com/ru-ru/library/… look. That's what you need. I can not give an example now - iRumba
  • And what should be passed there as a parameter? - SmiLe
  • OriginalSource, hike. It is only necessary to bring it to DependencyObject - iRumba
  • one
    What for do you need it? There is a chance that your real problem is solved differently. What effect do you want to achieve? - VladD
  • one
    Tell us more about the task. Perhaps we will suggest other solutions. Just since I got an idea about MVVM, I no longer need to get a VM object from the UI. Most likely, you do not need this either. - iRumba

1 answer 1

  1. Bring e to type ItemClickEventArgs , it is on your screen.
  2. e.ClickedItem (it will be available after the first item) to FiltersViewModel .

If both casts return a non-empty value, then everything is ok. Otherwise - someone missed.

In general, since you have a VM, I would rather go from the SelectedItem in the higher-level model, rather than from clicks on the form. This greatly facilitates the behavior when the select is done by code, and not by mouse click.