[英]DependencyProperty Binding Does Not Update To Collection CurrentItem
[英]DoubleAnimation does not update DependencyProperty
我有以下課程:
public class BindableClock : DependencyObject, INotifyPropertyChanged
{
private DoubleAnimation animation = new DoubleAnimation
{
From = 0.0d,
To = 10.0d,
Duration = new Duration(TimeSpan.FromDays(1d)),
BeginTime = TimeSpan.Zero
};
private Storyboard storyboard = new Storyboard { Duration = Duration.Automatic };
public double BogusDouble
{
get { return (double)GetValue(BogusDoubleProperty); }
set { SetValue(BogusDoubleProperty, value); }
}
// Using a DependencyProperty as the backing store for BogusDouble. This enables animation, styling, binding, etc...
public static readonly DependencyProperty BogusDoubleProperty =
DependencyProperty.Register("BogusDouble", typeof(double), typeof(BindableClock), new PropertyMetadata(0.0d, BogusDoubleChangedCallback));
public static void BogusDoubleChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var clock = d as BindableClock;
clock.TimeSpan = clock.storyboard.GetCurrentTime();
}
public TimeSpan TimeSpan {get; set;}
public BindableClock(bool start)
{
Storyboard.SetTarget(animation, this);
Storyboard.SetTargetProperty(animation, "BogusDouble");
storyboard.Children.Add(animation);
Value = TimeSpan.ToString(Format);
if (start)
storyboard.Begin();
}
public void Begin()
{
storyboard.Begin();
}
public void Stop()
{
storyboard.Stop();
}
}
我期望在運行Begin()
方法之后, BogusDouble
屬性將被更新幾次,並且BogusDoubleChangedCallback
都會被升高。 但事實並非如此。
知道為什么嗎?
故事板的持續時間應該是一天? 我認為這將需要一些時間才能進行第一次更改。 還是我想念這里的東西...?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.