Set IsEnabled Property of ComboBox Based on SelectedItem

I want to enable/disable a ComboBox based on if there is an item selected in another ComboBox. I was able to get it working by setting a trigger on the Style, but that overrides my custom global style for the combobox. Is there another way to get the same functionality without losing my style?

<ComboBox Grid.Column="1" Grid.Row="1"
              Name="AnalysisComboBox" 
              MinWidth="200"
              VerticalAlignment="Center" HorizontalAlignment="Left"
              ItemsSource="{Binding Path=AvailableAnalysis}">

        <ComboBox.Style>
            <Style TargetType="{x:Type ComboBox}">
                <Setter Property="IsEnabled" Value="True" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem,ElementName=ApplicationComboBox}" Value="{x:Null}">
                        <Setter Property="IsEnabled" Value="False" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ComboBox.Style>
    </ComboBox>
6
задан Anatoliy Nikolaev 5 August 2013 в 05:33
поделиться