Today I needed to control the enabled property of a button "Remove Item" on my form depending on wheather there was a selected item in a Listbox.

Here's how 


<Button Content="Remove" Click="OnRemoveTranstion">
<Button.Style>
<Style>
    <Style.Triggers>
        <DataTrigger Binding ="{Binding ElementName=listDetails, Path=SelectedIndex}" Value="-1">
            <Setter Property="Button.IsEnabled" Value="false"/>
        </DataTrigger>
    </Style.Triggers>
</Style>
</Button.Style>
</Button>
 

About Brian Keating
Brian Keating
Professional Software Developer, .NET / C++ / Java View all posts by Brian Keating →