【问题标题】:Move a label in XAML在 XAML 中移动标签
【发布时间】:2018-03-05 20:35:06
【问题描述】:

我要做的只是将标签从一个位置移动到另一个位置,但是当我使用以下代码并运行应用程序时,IDE 告诉我应用程序进入中断模式,然后停止。

以下代码是我在 Grid 中的所有代码,没有其他代码,并且 .cs 文件是干净的(只有带有 initializeComponents 的构造函数)。

我正在使用 Visual Studio 2017 企业版中的 Blend

<Label x:Name="labelTitle" Foreground="White" FontSize="36" FontWeight="Bold"  HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
        <Label.Triggers>
            <EventTrigger RoutedEvent="Label.Loaded">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation
                            Storyboard.TargetName="labelTitle"
                            Storyboard.TargetProperty="(Canvas.Top)"
                            To="500" Duration="0:0:10" />                           
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </Label.Triggers>
        Welcome
    </Label>

请帮帮我,我不知道怎么了

【问题讨论】:

    标签: c# wpf xaml storyboard doubleanimation


    【解决方案1】:

    NaN 错误出现在代码上方。要删除 NaN 错误,请在上述代码中的 Double 动画中添加“From”和“To”。 从="100" 到="500" 持续时间="0:0:10"

    同时在 labelTitle 中更改 Foreground="Black",这样标签就会可见。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多