c#故事板开始()未启动
我通过c#故事板开始()未启动,c#,wpf,xaml,storyboard,C#,Wpf,Xaml,Storyboard,我通过在画布上有大约50个元素。也是嵌套的。当的位置与传感器数据位置匹配时,我想更改其不透明度。代码一直工作到Begin()方法。它不会出错,也不会做任何事情。我还尝试创建不同的名称范围,但无法锁定正确的名称空间。除了此之外的任何内容都不能用于Begin()方法。如果我在If语句中创建一个新的作用域:“If(wantedNode是System.Windows.Shapes.Path)”,它会使它开始()一次,不会触发,而且永远不会回来 if (angle > 0) {
在画布上有大约50个
元素。
也是嵌套的。当
的位置与传感器数据位置匹配时,我想更改其不透明度。代码一直工作到Begin()方法。它不会出错,也不会做任何事情。我还尝试创建不同的名称范围
,但无法锁定正确的名称空间。除了此之外的任何内容都不能用于Begin()方法。如果我在If语句中创建一个新的作用域:“If(wantedNode是System.Windows.Shapes.Path)
”,它会使它开始()一次,不会触发,而且永远不会回来
if (angle > 0)
{
if (angle <= 180 && angle > 150)
{
if (mag <= sweetSpot)
{
//posAlertTxt.Text = "On target...";
}
else if (mag <= step)
{
selectedStep = "step0108";
}
else if (mag <= step * 2)
.
.
.
.
最后,XAML:
.
.
.
.
<Viewbox Name="forceGradientContainer" Width="126" Height="457"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="117" Canvas.Top="17">
<Canvas Name="indicatorBounds" Width="126.378" Height="457.004">
<Canvas Name="holder">
.
.
.
.
<Path Fill="IndianRed" Opacity="0" x:Name="step0108" Data="F1 M 28.802,209.027 L 49.252,221.067 C 47.922,223.377 47.162,226.057 47.162,228.917 L 23.432,228.917 C 23.432,221.667 25.392,214.867 28.802,209.027 Z"/>`
.
.
.
</Canvas>
</Canvas>
</Viewbox>
。
.
.
.
.
.
.
.
`
.
.
.
试试看
而不是
RegisterName("redBrush", redBrush);
Storyboard.SetTargetName(opacityAnimation, "redBrush");
为什么不直接设置元素本身的不透明度的动画呢
Storyboard.SetTarget(opacityAnimation, wantedChild);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
这就成功了。谢谢看起来AutoReverse参数工作不正常。这一定是因为当传感器移动时(在上一次调用消失之前),会再次调用该函数。是否仍要对此进行冒泡?请尝试在情节提要实例中设置AutoReverse属性:
sb.AutoReverse=true代码>。可能opacityImation在将其添加到sb
时采用了AutoReverse的值,默认为false。No go。在第一次开始后,我创建了另一个动画,将不透明度设置为0。这仍然有点不确定,但做得更好。
RegisterName("redBrush", redBrush);
Storyboard.SetTargetName(opacityAnimation, "redBrush");
Storyboard.SetTarget(opacityAnimation, wantedChild);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));