C#故事板从下到上绘制网格

C# storyboard draw grid from bottom to top

我有一个网格(也可以是一个矩形),我想从它的底部到顶部绘制它。好长的直线条。

                                    <Grid Grid.Row="2" Background="AliceBlue" x:Name="SkillBar11">
                                    <TextBlock Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,40" FontSize="16">IV</TextBlock>
                                </Grid>

我可以用 C# 中的这段代码让它从中间到顶部和底部绘制:

        Storyboard s = new Storyboard();
        DoubleAnimation doubleAni = new DoubleAnimation();
        doubleAni.To = SkillBar11.ActualHeight;
        doubleAni.From = 0;
        doubleAni.Duration = new Duration(TimeSpan.FromSeconds(1));
        Storyboard.SetTarget(doubleAni, SkillBar11);
        doubleAni.EnableDependentAnimation = true;
        s.Children.Add(doubleAni);

        Storyboard.SetTargetProperty(doubleAni, "Height");
        s.Begin();

但我不能让它从底部到顶部绘制,而不是从中间到底部和顶部绘制。有人可以帮我吗? :)

我找到答案了。您可以通过在网格属性中设置 Horizo​​ntal 或 Verticalalignment 来确定条形图的增长方式。这样它将从您对齐的位置开始!