本文整理汇总了C#中DependencyProperty类的典型用法代码示例。如果您正苦于以下问题:C# DependencyProperty类的具体用法?C# DependencyProperty怎么用?C# DependencyProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyProperty类属于命名空间,在下文中一共展示了DependencyProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBinding
public static void SetBinding (
DependencyObject target,
DependencyProperty property,
Binding binding ) {
throw new NotImplementedException ( );
}
示例2: Selector
public Selector ()
{
selectedItem = BuildProperty<UIElement> ("SelectedItem");
selectedItem.DependencyPropertyValueChanged += HandleSelectedItemChanged;
Items.CollectionChanged += HandleItemsChanged;
}
示例3: DependencyPropertyChangedEventArgs
public DependencyPropertyChangedEventArgs(
DependencyProperty property, object oldValue, object newValue)
{
Property = property;
OldValue = oldValue;
NewValue = newValue;
}
示例4: SingleAnimationGameAction
/// <summary>
/// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class.
/// </summary>
/// <param name="parent">The parent task.</param>
/// <param name="singleAnimation">The single animation.</param>
/// <param name="animation">The AnimationUI component.</param>
/// <param name="dependencyProperty">The dependency property to animate.</param>
public SingleAnimationGameAction(IGameAction parent, SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty)
: base(parent, "SingleAnimationGameAction" + instances++)
{
this.animation = animation;
this.singleAnimation = singleAnimation;
this.dependencyProperty = dependencyProperty;
}
示例5: RunTest
public void RunTest()
{
MHashTable *hash = create_hashtable();
Map map;
DependencyProperty dp1, dp2;
dp1 = new DependencyProperty ();
dp1.native = (IntPtr)0x01;
dp1.name = "DP-0x01";
map.obj = dp1;
hash->Insert (dp1.native, map.intptr);
dp2 = new DependencyProperty ();
dp2.native = (IntPtr)0x02;
dp2.name = "DP-0x02";
map.obj = dp2;
hash->Insert (dp2.native, map.intptr);
IntPtr ip = hash->Lookup ((IntPtr)0x01);
if (ip == IntPtr.Zero) {
Console.WriteLine ("null!?");
}
else {
map.intptr = ip;
DependencyProperty prop = (DependencyProperty)map.obj;
Console.WriteLine ("dp property = {0}", prop.name);
}
test_hashtable ((IntPtr)hash);
}
示例6: _OnApplyProperty
internal static void _OnApplyProperty(TextEditor This, DependencyProperty formattingProperty, object propertyValue, bool applyToParagraphs, PropertyValueAction propertyValueAction)
{
if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
{
return;
}
// Check whether the property is known
if (!TextSchema.IsParagraphProperty(formattingProperty) && !TextSchema.IsCharacterProperty(formattingProperty))
{
Invariant.Assert(false, "The property '" + formattingProperty.Name + "' is unknown to TextEditor");
return;
}
TextSelection selection = (TextSelection)This.Selection;
if (TextSchema.IsStructuralCharacterProperty(formattingProperty) &&
!TextRangeEdit.CanApplyStructuralInlineProperty(selection.Start, selection.End))
{
// Ignore structural commands fires in inappropriate context.
return;
}
TextEditorTyping._FlushPendingInputItems(This);
// Forget previously suggested horizontal position
TextEditorSelection._ClearSuggestedX(This);
// Break merged typing sequence
TextEditorTyping._BreakTypingSequence(This);
// Apply property
selection.ApplyPropertyValue(formattingProperty, propertyValue, applyToParagraphs, propertyValueAction);
}
示例7: BeginAnimation
/// <summary>
/// Starts animating a dependency property of a framework element to a
/// target value.
/// </summary>
/// <param name="target">The element to animate.</param>
/// <param name="animatingDependencyProperty">The dependency property to
/// animate.</param>
/// <param name="propertyPath">The path of the dependency property to
/// animate.</param>
/// <param name="targetValue">The value to animate the dependency
/// property to.</param>
/// <param name="timeSpan">The duration of the animation.</param>
/// <param name="easingFunction">The easing function to uses to
/// transition the data points.</param>
public static void BeginAnimation(
this FrameworkElement target,
DependencyProperty animatingDependencyProperty,
string propertyPath,
object targetValue,
TimeSpan timeSpan)
{
Storyboard storyBoard = target.Resources[GetStoryboardKey(propertyPath)] as Storyboard;
if (storyBoard != null)
{
// Save current value
object currentValue = target.GetValue(animatingDependencyProperty);
storyBoard.Stop();
// Restore that value so it doesn't snap back to its starting value
target.SetValue(animatingDependencyProperty, currentValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
}
storyBoard = CreateStoryboard(target, animatingDependencyProperty, propertyPath, ref targetValue, timeSpan);
storyBoard.Completed +=
(source, args) =>
{
storyBoard.Stop();
target.SetValue(animatingDependencyProperty, targetValue);
target.Resources.Remove(GetStoryboardKey(propertyPath));
};
target.Resources.Add(GetStoryboardKey(propertyPath), storyBoard);
storyBoard.Begin();
}
示例8: DependencyPropertyChangedEventArgs
public DependencyPropertyChangedEventArgs (DependencyProperty property, object oldValue, object newValue)
: this ()
{
this.Property = property;
this.OldValue = oldValue;
this.NewValue = newValue;
}
示例9: ClearValue
public void ClearValue(DependencyProperty dp)
{
if (IsSealed)
throw new InvalidOperationException("Cannot manipulate property values on a sealed Dependency Object");
_properties[dp] = null;
}
示例10: SuspendHandler
private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
{
if (_suspendedHandlers.ContainsKey(obj))
{
Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];
if (suspend)
{
Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "suspensions unexpectedly contain dependencyProperty");
suspensions[dependencyProperty] = true; // true = dummy value
}
else
{
Debug.Assert(suspensions.ContainsKey(dependencyProperty), "suspensions unexpectedly do not contain dependencyProperty");
suspensions.Remove(dependencyProperty);
if (suspensions.Count == 0)
{
_suspendedHandlers.Remove(obj);
}
}
}
else
{
Debug.Assert(suspend, "suspend unexpectedly false");
_suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
_suspendedHandlers[obj][dependencyProperty] = true;
}
}
示例11: Helper
public Helper(FrameworkElement obj, DependencyProperty property, Action<object, object> changed, object currentValue)
{
this.obj = obj;
this.property = property;
this.changed = changed;
this.currentValue = currentValue;
}
示例12: SuspendHandler
/// <summary>
/// Inherited code: Requires comment.
/// </summary>
/// <param name="obj">Inherited code: Requires comment 1.</param>
/// <param name="dependencyProperty">Inherited code: Requires comment 2.</param>
/// <param name="suspend">Inherited code: Requires comment 3.</param>
private static void SuspendHandler(this DependencyObject obj, DependencyProperty dependencyProperty, bool suspend)
{
if (_suspendedHandlers.ContainsKey(obj))
{
Dictionary<DependencyProperty, bool> suspensions = _suspendedHandlers[obj];
if (suspend)
{
Debug.Assert(!suspensions.ContainsKey(dependencyProperty), "Suspensions should not contain the property!");
// true = dummy value
suspensions[dependencyProperty] = true;
}
else
{
Debug.Assert(suspensions.ContainsKey(dependencyProperty), "Suspensions should contain the property!");
suspensions.Remove(dependencyProperty);
if (suspensions.Count == 0)
{
_suspendedHandlers.Remove(obj);
}
}
}
else
{
Debug.Assert(suspend, "suspend should be true!");
_suspendedHandlers[obj] = new Dictionary<DependencyProperty, bool>();
_suspendedHandlers[obj][dependencyProperty] = true;
}
}
示例13: GetValueCore
public override object GetValueCore(DependencyObject d, DependencyProperty dp)
{
if (Source != null)
return GetValueCore(Source);
if (ElementName == null)
if (d is FrameworkElement)
{
FrameworkElement element = (FrameworkElement)d;
while (element != null)
{
if (element.DataContext != null)
return GetValueCore(element.DataContext);
element = element.VisualParent as FrameworkElement;
}
return null;
}
else
return null;
if ((d is Visual) && dp == NameScope.NameScopeProperty)
return null;
INameScope nameScope = NameScope.GetNameScope(d);
if (nameScope == null)
return null;
object source = nameScope.FindName(ElementName);
return GetValueCore(source);
}
示例14: SingleAnimationGameAction
/// <summary>
/// Initializes a new instance of the <see cref="SingleAnimationGameAction" /> class.
/// </summary>
/// <param name="singleAnimation">The single animation.</param>
/// <param name="animation">The AnimationUI component.</param>
/// <param name="dependencyProperty">The dependency property to animate.</param>
/// <param name="scene">The associated scene.</param>
public SingleAnimationGameAction(SingleAnimation singleAnimation, AnimationUI animation, DependencyProperty dependencyProperty, Scene scene = null)
: base("SingleAnimationGameAction" + instances++, scene)
{
this.animation = animation;
this.singleAnimation = singleAnimation;
this.dependencyProperty = dependencyProperty;
}
示例15: SquareRootToken
public SquareRootToken ()
{
child = BuildProperty<Token> ("Child");
child.DependencyPropertyValueChanged += HandleValueChanged;
Child = new TextToken ();
}