47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Media.Animation;
|
|||
|
|
|
|||
|
|
namespace RazorEngineTest
|
|||
|
|
{
|
|||
|
|
public class PropertyStoryboard : Storyboard
|
|||
|
|
{
|
|||
|
|
private readonly SetterBaseCollection _setters = new SetterBaseCollection();
|
|||
|
|
|
|||
|
|
public SetterBaseCollection Setters => _setters;
|
|||
|
|
public new void Begin()
|
|||
|
|
{
|
|||
|
|
base.Begin();
|
|||
|
|
ApplyPropertySetters();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ApplyPropertySetters()
|
|||
|
|
{
|
|||
|
|
foreach (SetterBase setterBase in _setters)
|
|||
|
|
{
|
|||
|
|
if (setterBase is Setter setter && GetTarget(setter.TargetName) is DependencyObject targetObject)
|
|||
|
|
{
|
|||
|
|
DependencyProperty property = setter.Property;
|
|||
|
|
object value = setter.Value;
|
|||
|
|
|
|||
|
|
if (property != null)
|
|||
|
|
{
|
|||
|
|
targetObject.SetValue(property, value);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 快捷添加Setter的方法
|
|||
|
|
public void AddSetter(DependencyProperty property, object value)
|
|||
|
|
{
|
|||
|
|
_setters.Add(new Setter(property, value));
|
|||
|
|
}
|
|||
|
|
public DependencyObject GetTarget(string targetName) => throw new NotImplementedException();
|
|||
|
|
}
|
|||
|
|
}
|