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