Mam dwa ComboBoxes w następujący sposób
<StackPanel Orientation="Horizontal" >
<ComboBox x:Name="cbxOne" Style="{StaticResource demoStyle}" >
<ComboBoxItem >One</ComboBoxItem>
<ComboBoxItem >Two</ComboBoxItem>
<ComboBoxItem >All</ComboBoxItem>
</ComboBox>
<ComboBox x:Name="cbxTwo">
<ComboBoxItem >1</ComboBoxItem>
<ComboBoxItem >2</ComboBoxItem>
</ComboBox>
</StackPanel>
Próbowałem tego stylu
<Style x:Key="demoStyle" TargetType="{x:Type ComboBox}">
<Style.Triggers>
<Trigger Property="SelectedValue" Value="All">
<Setter Property="cbxTwo.Visibility" Value="Collapsed"></Setter>
</Trigger>
</Style.Triggers>
</Style>
Chcę, gdy pierwszy jest "Wszystkie", aby ukryć drugi za pomocą Xaml i wyzwalacz.
Dzięki
Odpowiedzi:
7 dla odpowiedzi № 1 <StackPanel>
<ComboBox Name="cbxOne">
<ComboBoxItem>One</ComboBoxItem>
<ComboBoxItem>Two</ComboBoxItem>
<ComboBoxItem>All</ComboBoxItem>
</ComboBox>
<ComboBox>
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBox.Style>
<Style TargetType="{x:Type ComboBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedItem.Content, ElementName=cbxOne}" Value="All">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
</StackPanel>