0
我有一个条形图,可以设置动画的值。动画代码看起来像WPF关键帧绑定
<UserControl.Resources>
<Storyboard x:Key="BootUp">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="MainBar">
<EasingDoubleKeyFrame KeyTime="0" Value="350"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="{Binding CurrentValue, ElementName=UserControl}"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
和C#
int ThisValue=200;
public int CurrentValue
{
get { return (int)ThisValue; }
set {
ThisValue=(int)value;
this.MainBar.ToolTip=value.ToString();
System.Windows.Media.Animation.Storyboard storyBoard = (System.Windows.Media.Animation.Storyboard)FindResource("BootUp");
storyBoard.Begin(this);
}
}
我认为这应该工作,但每次都返回
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=UserControl'. BindingExpression:Path=CurrentValue; DataItem=null; target element is 'EasingDoubleKeyFrame' (HashCode=27594380); target property is 'Value' (type 'Double')
这是怎么回事?
请问您的用户控件的名称为用户控件? –
是的,我试图将其更改为BarItem和对条款项目的引用,但它仍然无效。 – Bonzo