我想做的只是将标签从一个位置移动到另一个位置,但是当我使用以下代码并运行应用程序时,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>
请帮帮我,我不知道哪里出了问题
最佳答案
代码上方出现 NaN 错误。要删除 NaN 错误,请在上面代码的双动画中添加“From”和“To”。 从 ="100"到 ="500"持续时间 ="0:0:10"
同时在 labelTitle 中更改 Foreground="Black",因此标签将可见。
关于c# - 在 XAML 中移动标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46395627/