我想在按钮点击时清除组合框选择/内容,所有这些都在XAML中,没有代码。我正确使用故事板吗?我需要一个故事板吗?
我在ItemsControl中,所以浏览可视树并不容易,也很难看。
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<TextBlock FontSize="20"
Text="Sensitivity Parameter: "
VerticalAlignment="Center"/>
<ComboBox x:Name="cbSensitivityParameter2"
FontSize="20"
DisplayMemberPath="Name"
VerticalAlignment="Center">
<ComboBox.ItemsSource>
<MultiBinding Converter="{StaticResource parameter2SensitivityNameListConverter}"
UpdateSourceTrigger="PropertyChanged"
Mode="OneWay">
<Binding ElementName="tbUserLevel"
Path="IsChecked"/>
<Binding Path="Parameters"/>
</MultiBinding>
</ComboBox.ItemsSource>
</ComboBox>
<Button Style="{DynamicResource MetroCircleButtonStyle}"
Width="50"
Height="50"
Margin="10,0,0,0"
Visibility="{Binding ElementName=cbSensitivityParameter2, Path=SelectedIndex, Converter={StaticResource hideMeConverter}, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center">
<Rectangle Width="20" Height="20">
<Rectangle.Fill>
<VisualBrush Stretch="Fill"
Visual="{StaticResource appbar_delete}" />
</Rectangle.Fill>
</Rectangle>
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<SingleAnimationUsingKeyFrames Storyboard.TargetName="cbSensitivityParameter2" Storyboard.TargetProperty="SelectedIndex">
<LinearSingleKeyFrame Value="-1" />
</SingleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</StackPanel>
谢谢!