tags:

views:

100

answers:

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

+1  A: 

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.

Nicholas Armstrong