本文整理汇总了C#中System.Windows.PropertyPath类的典型用法代码示例。如果您正苦于以下问题:C# PropertyPath类的具体用法?C# PropertyPath怎么用?C# PropertyPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyPath类属于System.Windows命名空间,在下文中一共展示了PropertyPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDouble
///
/// <summary>
/// Helper to create double animation</summary>
///
public static Storyboard AddDouble(
this Storyboard sb,
int durationMs,
DependencyObject element,
PropertyPath path,
double from,
double to,
IEasingFunction easing = null
)
{
DoubleAnimation da;
da = new DoubleAnimation();
da.Duration = new Duration(TimeSpan.FromMilliseconds(durationMs));
da.From = from;
da.To = to;
if (easing != null)
{
da.EasingFunction = easing;
}
Storyboard.SetTarget(da, element);
Storyboard.SetTargetProperty(da, path);
sb.Children.Add(da);
return sb;
}
示例2: PropertyPathCtors
public void PropertyPathCtors ()
{
PropertyPath prop;
Assert.Throws <ArgumentOutOfRangeException>(() =>
prop = new PropertyPath ("first", "second")
, "#1");
Assert.Throws<ArgumentOutOfRangeException>(delegate {
prop = new PropertyPath (null, "arg1");
}, "null path throws ArgumentOutOfRangeException");
prop = new PropertyPath (Rectangle.WidthProperty);
Assert.AreEqual ("(0)", prop.Path, "Normal PropertyPath");
prop = new PropertyPath (Canvas.LeftProperty);
Assert.AreEqual ("(0)", prop.Path, "Attached PropertyPath");
prop = new PropertyPath (5);
Assert.IsNull (prop.Path, "numeric PropertyPath is null");
Assert.Throws<NullReferenceException> (delegate {
prop = new PropertyPath (null, null);
}, "Both null");
Assert.Throws<NullReferenceException> (delegate {
prop = new PropertyPath ("pathstring", null);
}, "second null");
prop = new PropertyPath ((string) null);
Assert.IsNull (prop.Path, "null PropertyPath is null");
}
示例3: SmoothSetAsync
public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue,
TimeSpan iDuration, CancellationToken iCancellationToken)
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration));
PropertyPath p = new PropertyPath("(0)", dp);
Storyboard.SetTargetProperty(anim, p);
Storyboard sb = new Storyboard();
sb.Children.Add(anim);
EventHandler handler = null;
handler = delegate
{
sb.Completed -= handler;
sb.Remove(@this);
@this.SetValue(dp, targetvalue);
tcs.TrySetResult(null);
};
sb.Completed += handler;
sb.Begin(@this, true);
iCancellationToken.Register(() =>
{
double v = (double)@this.GetValue(dp);
sb.Stop();
sb.Remove(@this);
@this.SetValue(dp, v);
tcs.TrySetCanceled();
});
return tcs.Task;
}
示例4: GetTypeFromName
private static Type GetTypeFromName (PropertyPath propertyPath, string name)
{
// HACK
return (Type)typeof(PropertyPath)
.GetMethod("GetTypeFromName", BindingFlags.Instance | BindingFlags.NonPublic)
.Invoke(propertyPath, new object[] { name, null });
}
示例5: CreateAnim
public static Storyboard CreateAnim(DependencyObject target, EquationType type, TimeSpan duration, PropertyPath property, double from, double to)
{
Storyboard sb = new Storyboard();
AddAnimation(sb, target, property, duration, type, from, to);
return sb;
}
示例6: AnimationInfo
public AnimationInfo(DependencyObject target, PropertyPath propertyPath, double startValue, double endValue, IEasingFunction easingFunction = null)
{
Target = target;
PropertyPath = propertyPath;
StartValue = startValue;
EndValue = endValue;
EasingFunction = easingFunction;
}
示例7: CanCreateCommand
public virtual Boolean CanCreateCommand( PropertyPath path, DependencyObject target )
{
if ( DesignTimeHelper.GetIsInDesignMode() )
{
return false;
}
return path != null && ( target is FrameworkElement || target is FrameworkContentElement );
}
示例8: GetPath
internal static PropertyPath GetPath(DependencyProperty property)
{
PropertyPath path;
if (!PropertyPaths.TryGetValue(property, out path))
{
path = new PropertyPath(property);
PropertyPaths[property] = path;
}
return path;
}
示例9: GetPath
internal static PropertyPath GetPath(string path)
{
PropertyPath propertyPath;
if (!PropertyPaths.TryGetValue(path, out propertyPath))
{
propertyPath = new PropertyPath(path);
PropertyPaths[path] = propertyPath;
}
return propertyPath;
}
示例10: GetPath
internal static PropertyPath GetPath(int index)
{
PropertyPath path;
if (!IndexPaths.TryGetValue(index, out path))
{
path = new PropertyPath($"[{index}]");
IndexPaths[index] = path;
}
return path;
}
示例11: PrepareXmlBinding
PropertyPath PrepareXmlBinding(PropertyPath path)
{
if (path == null)
{
DependencyProperty targetDP = TargetProperty;
Type targetType = targetDP.PropertyType;
string pathString;
if (targetType == typeof(Object))
{
if (targetDP == System.Windows.Data.BindingExpression.NoTargetProperty ||
targetDP == System.Windows.Controls.Primitives.Selector.SelectedValueProperty ||
targetDP.OwnerType == typeof(LiveShapingList)
)
{
// these properties want the "value" - i.e. the text of
// the first (and usually only) XmlNode
pathString = "/InnerText";
}
else if (targetDP == FrameworkElement.DataContextProperty ||
targetDP == CollectionViewSource.SourceProperty)
{
// these properties want the entire collection
pathString = String.Empty;
}
else
{
// most object-valued properties want the (current) XmlNode itself
pathString = "/";
}
}
else if (targetType.IsAssignableFrom(typeof(XmlDataCollection)))
{
// these properties want the entire collection
pathString = String.Empty;
}
else
{
// most other properties want the "value"
pathString = "/InnerText";
}
path = new PropertyPath(pathString);
}
// don't bother to create XmlWorker if we don't even have a valid path
if (path.SVI.Length > 0)
{
// tell Xml Worker if desired result is collection, in order to get optimization
SetValue(Feature.XmlWorker, new XmlBindingWorker(this, path.SVI[0].drillIn == DrillIn.Never));
}
return path;
}
示例12: LocBindingTarget
public LocBindingTarget(LocalizationInstance loc, FrameworkElement targetObject, PropertyPath path)
{
_locInstance = loc;
_lbCollection.Add(this);
_path = path;
targetObject.DataContextChanged += new DependencyPropertyChangedEventHandler(update_binding);
update_binding(targetObject, new DependencyPropertyChangedEventArgs(FrameworkElement.DataContextProperty, null, targetObject.DataContext));
}
示例13: SetName
public void SetName ()
{
Storyboard sb = new Storyboard ();
PropertyPath path = new PropertyPath ("Width");
Storyboard.SetTargetProperty (sb, path);
PropertyPath native = Storyboard.GetTargetProperty (sb);
Assert.AreNotEqual (path, native, "#1");
Assert.IsFalse (path == native, "#2");
Assert.AreEqual(path.Path, native.Path, "#3");
Assert.AreEqual (path.Path, "Width", "#4");
}
示例14: GetPath
private static PropertyPath GetPath(DependencyProperty property)
{
PropertyPath path;
if (PropertyPaths.TryGetValue(property, out path))
{
return path;
}
path = new PropertyPath(property);
PropertyPaths[property] = path;
return path;
}
示例15: PropertyPathWorker
private PropertyPathWorker(PropertyPath path, DataBindEngine engine)
{
_parent = path;
_arySVS = new SourceValueState[path.Length];
_engine = engine;
// initialize each level to NullDataItem, so that the first real
// item will force a change
for (int i=_arySVS.Length-1; i>=0; --i)
{
_arySVS[i].item = BindingExpression.CreateReference(BindingExpression.NullDataItem);
}
}