创建故事板动画但不使用行和列 wpf xaml c#
Created storyboard animation but not worikng with rows and colums wpf xaml c#
完成复选框选择后,两个按钮将动画化我只想这样做,该网格以全视图显示我尝试了 rowspan 和 columspan 但没有工作不知道如何使用它。在 window.
的另一侧显示我的动画连接
代码=>
<Window x:Class="Login.View.ControlPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ControlPanel" Height="300" Width="300">
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Margin"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Height"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0 0 0 -66">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="SilverLight" Margin="10"/>
<TextBlock Text=".Net Framework" Margin="10" Grid.Row="1"/>
<TextBlock Text=" Printer Drivers" Margin="10" Grid.Row="2"/>
<TextBlock Text="Email Listner" Margin="10" Grid.Row="3"/>
<TextBlock Text="Scanner Component" Margin="10" Grid.Row="4"/>
<TextBlock Text="Scanner Driver Version 1.0.0" Margin="10" Grid.Row="5"/>
<CheckBox x:Name="cbSilverlight" Grid.Column="1" Margin="10"/>
<CheckBox x:Name="cbNetframework" Grid.Column="1" Grid.Row="1" Margin="10"/>
<CheckBox x:Name="cbAlisprinter" Grid.Column="1" Grid.Row="2" Margin="10"/>
<CheckBox x:Name="cbEmaillistner" Grid.Column="1" Grid.Row="3" Margin="10"/>
<CheckBox x:Name="cbScanner" Grid.Column="1" Grid.Row="4" Margin="10"/>
<CheckBox x:Name="cbScannerDriver" Grid.Column="1" Grid.Row="5" Margin="10"/>
<Grid Grid.Row="7" Name="ControlsGrid" Height="66" VerticalAlignment="Bottom" Background="Black" Margin="0 0 0 -66">
<WrapPanel HorizontalAlignment="Right">
<Button Height="30" Width="70" Margin="10" Foreground="White" Background="Green">Cancel</Button>
<Button Height="30" Width="70" Margin="10" Foreground="White" Background="Green">Proceed</Button>
</WrapPanel>
</Grid>
</Grid>
</Window>
解决方法:我已经修改了你的代码来解决这个问题。
修改后的代码:
<Window x:Class="Login.View.ControlPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ControlPanel" Height="400" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Margin"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Height"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0 0 0 -66">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="SilverLight" Margin="10"/>
<TextBlock Text=".Net Framework" Margin="10" Grid.Row="1"/>
<TextBlock Text="ALIS Printer Drivers" Margin="10" Grid.Row="2"/>
<TextBlock Text="ALIS Email Listner" Margin="10" Grid.Row="3"/>
<TextBlock Text="ALIS Scanner Component" Margin="10" Grid.Row="4"/>
<TextBlock Text="ALIS Scanner Driver Version 1.0.0" Margin="10" Grid.Row="5"/>
<CheckBox x:Name="cbSilverlight" Grid.Column="1" Margin="10"/>
<CheckBox x:Name="cbNetframework" Grid.Column="1" Grid.Row="1" Margin="10"/>
<CheckBox x:Name="cbAlisprinter" Grid.Column="1" Grid.Row="2" Margin="10"/>
<CheckBox x:Name="cbEmaillistner" Grid.Column="1" Grid.Row="3" Margin="10"/>
<CheckBox x:Name="cbScanner" Grid.Column="1" Grid.Row="4" Margin="10"/>
<CheckBox x:Name="cbScannerDriver" Grid.Column="1" Grid.Row="5" Margin="10"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DockPanel Name="ControlsGrid" Height="66" Background="Black" VerticalAlignment="Bottom" Margin="0,0,0,-66">
<Button DockPanel.Dock= "Right" Height="30" Width="70" Margin="10,5" Foreground="White" Background="Green" HorizontalAlignment="Right">Cancel</Button>
<Button DockPanel.Dock="Right" Height="30" Width="70" Margin="10,5" Foreground="White" Background="Green" HorizontalAlignment="Right">Proceed</Button>
</DockPanel>
</Grid>
</Grid>
</Window>
完成复选框选择后,两个按钮将动画化我只想这样做,该网格以全视图显示我尝试了 rowspan 和 columspan 但没有工作不知道如何使用它。在 window.
的另一侧显示我的动画连接代码=>
<Window x:Class="Login.View.ControlPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ControlPanel" Height="300" Width="300">
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Margin"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Height"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0 0 0 -66">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="SilverLight" Margin="10"/>
<TextBlock Text=".Net Framework" Margin="10" Grid.Row="1"/>
<TextBlock Text=" Printer Drivers" Margin="10" Grid.Row="2"/>
<TextBlock Text="Email Listner" Margin="10" Grid.Row="3"/>
<TextBlock Text="Scanner Component" Margin="10" Grid.Row="4"/>
<TextBlock Text="Scanner Driver Version 1.0.0" Margin="10" Grid.Row="5"/>
<CheckBox x:Name="cbSilverlight" Grid.Column="1" Margin="10"/>
<CheckBox x:Name="cbNetframework" Grid.Column="1" Grid.Row="1" Margin="10"/>
<CheckBox x:Name="cbAlisprinter" Grid.Column="1" Grid.Row="2" Margin="10"/>
<CheckBox x:Name="cbEmaillistner" Grid.Column="1" Grid.Row="3" Margin="10"/>
<CheckBox x:Name="cbScanner" Grid.Column="1" Grid.Row="4" Margin="10"/>
<CheckBox x:Name="cbScannerDriver" Grid.Column="1" Grid.Row="5" Margin="10"/>
<Grid Grid.Row="7" Name="ControlsGrid" Height="66" VerticalAlignment="Bottom" Background="Black" Margin="0 0 0 -66">
<WrapPanel HorizontalAlignment="Right">
<Button Height="30" Width="70" Margin="10" Foreground="White" Background="Green">Cancel</Button>
<Button Height="30" Width="70" Margin="10" Foreground="White" Background="Green">Proceed</Button>
</WrapPanel>
</Grid>
</Grid>
</Window>
解决方法:我已经修改了你的代码来解决这个问题。
修改后的代码:
<Window x:Class="Login.View.ControlPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ControlPanel" Height="400" Width="500">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.Triggers>
<EventTrigger RoutedEvent="CheckBox.Checked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Margin"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="CheckBox.Unchecked">
<BeginStoryboard>
<!--<Storyboard>
<DoubleAnimation Storyboard.TargetName="ControlsGrid"
Storyboard.TargetProperty="Height"
To="0" Duration="0:0:0.3" />
</Storyboard>-->
<Storyboard>
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="ControlsGrid">
<EasingThicknessKeyFrame KeyTime="0:0:0.3" Value="0 0 0 -66">
<EasingThicknessKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseInOut"/>
</EasingThicknessKeyFrame.EasingFunction>
</EasingThicknessKeyFrame>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="SilverLight" Margin="10"/>
<TextBlock Text=".Net Framework" Margin="10" Grid.Row="1"/>
<TextBlock Text="ALIS Printer Drivers" Margin="10" Grid.Row="2"/>
<TextBlock Text="ALIS Email Listner" Margin="10" Grid.Row="3"/>
<TextBlock Text="ALIS Scanner Component" Margin="10" Grid.Row="4"/>
<TextBlock Text="ALIS Scanner Driver Version 1.0.0" Margin="10" Grid.Row="5"/>
<CheckBox x:Name="cbSilverlight" Grid.Column="1" Margin="10"/>
<CheckBox x:Name="cbNetframework" Grid.Column="1" Grid.Row="1" Margin="10"/>
<CheckBox x:Name="cbAlisprinter" Grid.Column="1" Grid.Row="2" Margin="10"/>
<CheckBox x:Name="cbEmaillistner" Grid.Column="1" Grid.Row="3" Margin="10"/>
<CheckBox x:Name="cbScanner" Grid.Column="1" Grid.Row="4" Margin="10"/>
<CheckBox x:Name="cbScannerDriver" Grid.Column="1" Grid.Row="5" Margin="10"/>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DockPanel Name="ControlsGrid" Height="66" Background="Black" VerticalAlignment="Bottom" Margin="0,0,0,-66">
<Button DockPanel.Dock= "Right" Height="30" Width="70" Margin="10,5" Foreground="White" Background="Green" HorizontalAlignment="Right">Cancel</Button>
<Button DockPanel.Dock="Right" Height="30" Width="70" Margin="10,5" Foreground="White" Background="Green" HorizontalAlignment="Right">Proceed</Button>
</DockPanel>
</Grid>
</Grid>
</Window>