本文整理汇总了C#中DependencyObject类的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject类的具体用法?C# DependencyObject怎么用?C# DependencyObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DependencyObject类属于命名空间,在下文中一共展示了DependencyObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBinding
public static void SetBinding (
DependencyObject target,
DependencyProperty property,
Binding binding ) {
throw new NotImplementedException ( );
}
示例2: HandlePreviewMouseDown
/// <summary>
/// Handles the <see cref="Mouse.PreviewMouseDownEvent"/>.
/// </summary>
private static void HandlePreviewMouseDown(DependencyObject element, MouseDevice device, MouseButton button, ref RoutedEventData data)
{
if (button == MouseButton.Left)
{
((SliderBase)element).Focus();
}
}
示例3: Parse
/// <summary>
/// Parses the specified message text.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="text">The message text.</param>
/// <returns>The triggers parsed from the text.</returns>
public static IEnumerable<TriggerBase> Parse(DependencyObject target, string text)
{
if (string.IsNullOrEmpty(text))
{
return new TriggerBase[0];
}
var triggers = new List<TriggerBase>();
var messageTexts = Split(text, ';');
foreach (var messageText in messageTexts)
{
var triggerPlusMessage = LongFormatRegularExpression.IsMatch(messageText)
? Split(messageText, '=')
: new[] { null, messageText };
var messageDetail = triggerPlusMessage.Last()
.Replace("[", string.Empty)
.Replace("]", string.Empty)
.Trim();
var trigger = CreateTrigger(target, triggerPlusMessage.Length == 1 ? null : triggerPlusMessage[0]);
var message = CreateMessage(target, messageDetail);
trigger.Actions.Add(message);
triggers.Add(trigger);
}
return triggers;
}
示例4: OnBehaviorsChanged
private static void OnBehaviorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var oldBehaviorCollection = (BehaviorCollection)e.OldValue;
var newBehaviorCollection = (BehaviorCollection)e.NewValue;
if (oldBehaviorCollection == newBehaviorCollection)
{
return;
}
if (oldBehaviorCollection != null)
{
#if WINDOWS_PHONE
var associatedObject = typeof(BehaviorCollection)
.GetProperty("AssociatedObject", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(oldBehaviorCollection);
#else
var associatedObject = oldBehaviorCollection.AssociatedObject;
#endif
if (associatedObject != null)
{
oldBehaviorCollection.Detach();
}
}
if (newBehaviorCollection == null || d == null)
{
return;
}
newBehaviorCollection.Attach(d);
}
示例5: AddPreviewAxisChangedHandler
/// <summary>
/// Adds a handler for the PreviewAxisChanged attached event to the specified element.
/// </summary>
/// <param name="element">The element to which to add the handler.</param>
/// <param name="handler">The handler to add to the specified element.</param>
public static void AddPreviewAxisChangedHandler(DependencyObject element, UpfGamePadAxisChangedEventHandler handler)
{
Contract.Require(element, "element");
Contract.Require(handler, "handler");
IInputElementHelper.AddHandler(element, PreviewAxisChangedEvent, handler);
}
示例6: PositionPropertyChanged
//------------------------------------------------------
//
// Public Properties
//
//-----------------------------------------------------
private static void PositionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
PointLightBase target = ((PointLightBase) d);
target.PropertyChanged(PositionProperty);
}
示例7: OnMenuFlyoutChanged
/// <summary>
/// Handles changes to the MenuFlyout DependencyProperty.
/// </summary>
/// <param name="o">DependencyObject that changed.</param>
/// <param name="e">Event data for the DependencyPropertyChangedEvent.</param>
private static void OnMenuFlyoutChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
var element = o as FrameworkElement;
if (null != element)
{
// just in case we were here before and there is no new menu
element.Holding -= OnElementHolding;
MenuFlyout oldMenuFlyout = e.OldValue as MenuFlyout;
if (null != oldMenuFlyout)
{
// Remove previous attachment
element.SetValue(FlyoutBase.AttachedFlyoutProperty, null);
}
MenuFlyout newMenuFlyout = e.NewValue as MenuFlyout;
if (null != newMenuFlyout)
{
// attach using FlyoutBase to easier show the menu
element.SetValue(FlyoutBase.AttachedFlyoutProperty, newMenuFlyout);
// need to show it
element.Holding += OnElementHolding;
}
}
}
示例8: DirectionPropertyChanged
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
private static void DirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
DirectionalLight target = ((DirectionalLight) d);
target.PropertyChanged(DirectionProperty);
}
示例9: OnMinimumDistanceBetweenChildrenPropertyChanged
/// <summary>
/// MinimumDistanceBetweenChildrenProperty property changed handler.
/// </summary>
/// <param name="d">OrientedPanel that changed its MinimumDistanceBetweenChildren.</param>
/// <param name="e">Event arguments.</param>
private static void OnMinimumDistanceBetweenChildrenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
OrientedPanel source = (OrientedPanel)d;
double oldValue = (double)e.OldValue;
double newValue = (double)e.NewValue;
source.OnMinimumDistanceBetweenChildrenPropertyChanged(oldValue, newValue);
}
示例10: VisualTreeChangeEventArgs
public VisualTreeChangeEventArgs(DependencyObject parent, DependencyObject child, int childIndex, VisualTreeChangeType changeType)
{
Parent = parent;
Child = child;
ChildIndex = childIndex;
ChangeType = changeType;
}
示例11: OnHeaderChanged
/// <summary>
/// Called when HeaderProperty is invalidated on "d."
/// </summary>
private static void OnHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
HeaderedItemsControl ctrl = (HeaderedItemsControl) d;
ctrl.SetValue(HasHeaderPropertyKey, (e.NewValue != null) ? BooleanBoxes.TrueBox : BooleanBoxes.FalseBox);
ctrl.OnHeaderChanged(e.OldValue, e.NewValue);
}
示例12: CheckTarget
static void CheckTarget (DependencyObject target)
{
if (target == null)
throw new ArgumentNullException ("target");
if (!(target is TextBox))
throw new ArgumentException ("target is not a TextBox", "target");
}
示例13: OnSizePropertyChanged
private static void OnSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
PredefinedMarkerStyle style = d as PredefinedMarkerStyle;
style.OnPropertyChanged("Size");
style.OnPropertyChanged("OffsetX");
style.OnPropertyChanged("OffsetY");
}
示例14: RemoveGenericInteractionHandler
/// <summary>
/// Removes a handler for the GenericInteraction attached event to the specified element.
/// </summary>
/// <param name="element">The element from which to remove the handler.</param>
/// <param name="handler">The handler to remove from the specified element.</param>
public static void RemoveGenericInteractionHandler(DependencyObject element, UpfTouchTapEventHandler handler)
{
Contract.Require(element, "element");
Contract.Require(handler, "handler");
IInputElementHelper.RemoveHandler(element, GenericInteractionEvent, handler);
}
示例15: AddPreviewTapHandler
/// <summary>
/// Adds a handler for the PreviewGenericInteraction attached event to the specified element.
/// </summary>
/// <param name="element">The element to which to add the handler.</param>
/// <param name="handler">The handler to add to the specified element.</param>
public static void AddPreviewTapHandler(DependencyObject element, UpfGenericInteractionEventHandler handler)
{
Contract.Require(element, "element");
Contract.Require(handler, "handler");
IInputElementHelper.AddHandler(element, PreviewGenericInteractionEvent, handler);
}