1

Can I use a trigger on the SelectedItem property in any control that supports SelectedItem?

<Trigger
    Property="SelectedItem"
    Value="{x:NotNull}" >
</Trigger>

What I want is when the SelectedItem is Not null for the trigger to fire.

Tnx

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Chris Nicol
  • 10,256
  • 7
  • 39
  • 49

1 Answers1

2

You can use a trigger on the SelectedItem property, but you cannot (by default) trigger when that value is not null.

You've got two options:

  1. Rephrase your trigger to trigger on null (using Value="{x:Null}"), and then have your 'default' value be what you want to happen when a value is not null
  2. Write a ValueConverter that returns true when the value it is passed is not null.

This stack overflow post describes both of these options in detail.

Community
  • 1
  • 1
Nicholas Armstrong
  • 5,814
  • 2
  • 28
  • 18