我希望能够在单击按钮时将网格转换到页面底部。目前我正在使用TranslateTransform来实现这一点,但问题是我必须给出一个整数值,我必须转换网格,当容器的高度发生变化时,网格会发生变化。我的故事板:
<Storyboard x:Name="LowerChamberSlideDown">
<DoubleAnimation Storyboard.TargetName="HeaderTrans"
BeginTime="0:0:1"
Storyboard.TargetProperty="Y"
To="288"
Duration="0:0:2"/>
</Storyboard>
我的网格:
<Grid x:Name="LowerChamberHeader"
Grid.Row="0"
VerticalAlignment="Top">
<Grid.RenderTransform>
<TranslateTransform x:Name="HeaderTrans" Y="0"></TranslateTransform>
</Grid.RenderTransform>
<TextBlock Text="Lower Chamber"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="15,0,0,0"
Foreground="White"/>
<Button Height="20"
HorizontalAlignment="Right"
Margin="0,0,10,0">
<Button.Background>
<ImageBrush ImageSource="Assets/bmpExpandCollapse.bmp"
Stretch="Uniform"/>
</Button.Background>
</Button>
<Grid.Background>
<ImageBrush ImageSource="Assets/bmpBlueImage.bmp"/>
</Grid.Background>
</Grid>
有没有办法在动画中使用VerticalAlignment属性并将其设置为底部以转换网格?
答案 0 :(得分:0)
从以下链接获得此答案: How to animate Margin property in WPF
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GroupTileSecond"
Storyboard.TargetProperty="HorizontalAlignment">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<HorizontalAlignment>Center</HorizontalAlignment>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
谢谢,
杰西
答案 1 :(得分:0)
我找不到一个解决方案,它也显示了网格到屏幕底部的良好过渡,所以我通过确定OnSizeChanged
事件的屏幕高度然后重新计算{{1}来解决了这个问题来自代码的属性。