I have a rather classic UI situation - two ListBoxes named SelectedItems and AvailableItems - the idea being that the items you have already selected live in SelectedItems, while the items that are available for adding to SelectedItems (i.e. every item that isn't already in there) live in AvailableItems.

Also, I have the < and > buttons to move the current selection from one list to the other (in addition to double clicking, which works fine).

Is it possible in WPF to set up a style/trigger to enable or disable the move buttons depending on anything being selected in either ListBox? SelectedItems is on the left side, so the < button will move the selected AvailableItems to that list. However, if no items are selected (AvailableItems.SelectedIndex == -1), I want this button to be disabled (IsEnabled == false) - and the other way around for the other list/button.

Is this possible to do directly in XAML, or do I need to create complex logic in the codebehind to handle it?

Thanks for any insight!

+2  A: 

Here's your solution.


Correct you are - thank you very much! :)

Rune Jacobsen

I love WPF. Its fun trying to do as much UI logic in xaml as possible.

if by fun you mean utterly, utterly horrible, the-only-way-to-make-it-worse-would-be-with-regex, then yeah its great fun
Andrew Bullock
@andrew Funny, I think Forms programming is roughly equivalent to mashing a nut with a rubber mallet. But I guess some people like that kind of thing.