【发布时间】:2011-01-19 21:50:12
【问题描述】:
我正在寻找允许根据选择的单选按钮运行某个情节提要的代码。场景是先选择一个单选按钮,然后单击“下一步”按钮运行故事板。例如,如果选择了第一个单选按钮并单击了“下一步”按钮,则应播放第一个故事板。任何想法都受到高度赞赏。提前谢谢你。
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ClickCount.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
<Storyboard x:Key="Storyboard1">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
<EasingColorKeyFrame KeyTime="0" Value="Red"/>
<EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FF00FFED"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard2">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
<EasingColorKeyFrame KeyTime="0" Value="Red"/>
<EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FF5AFF00"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard3">
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="border">
<EasingColorKeyFrame KeyTime="0" Value="Red"/>
<EasingColorKeyFrame KeyTime="0:0:0.5" Value="#FFFFF500"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<RadioButton GroupName="Os" Content="Storyboard 1" IsChecked="True" FontSize="16" Margin="10,10,10,0"/>
<RadioButton GroupName="1" Content="Storyboard 2" Margin="10,31,0,0" FontSize="16" />
<RadioButton GroupName="1" Content="Storyboard 3" Margin="10,50,0,0" FontSize="16" />
<Button x:Name="Next" Content="Next>" Width="75.06" Height="23" IsDefault="True"
Click="ClickNextButton" VerticalAlignment="Top" />
<Border x:Name="border" BorderBrush="Black" BorderThickness="1"
HorizontalAlignment="Center" Height="100" VerticalAlignment="Center"
Width="100" Background="Red"/>
</Grid>
C#:
public partial class MainWindow : Window
public MainWindow()
{
this.InitializeComponent();
}
private void ClickNextButton(object sender, System.Windows.RoutedEventArgs e)
{
Counter += 1;
if (Counter == 1) { }
if (Counter == 2) { }
}
}
【问题讨论】:
标签: wpf wpf-controls binding