本文整理汇总了C#中System.Windows.DependencyObject.SaftyInvoke方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.SaftyInvoke方法的具体用法?C# DependencyObject.SaftyInvoke怎么用?C# DependencyObject.SaftyInvoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.SaftyInvoke方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelayBinding
protected DelayBinding(BindingExpressionBase bindingExpression, DependencyObject bindingTarget, DependencyProperty bindingTargetProperty, TimeSpan delay)
{
_bindingExpression = bindingExpression;
_delay = delay;
// Subscribe to notifications for when the target property changes. This event handler will be
// invoked when the user types, clicks, or anything else which changes the target property
_descriptor = DependencyPropertyDescriptor.FromProperty(bindingTargetProperty, bindingTarget.GetType());
// Add support so that the Enter key causes an immediate commit
bindingTarget.SaftyInvoke<FrameworkElement>(el =>
{
el.Loaded += OnBindingTargetLoaded;
});
// Setup the timer, but it won't be started until changes are detected
_timer = new DispatcherTimer();
_timer.Tick += TimerTick;
_timer.Interval = _delay;
}
示例2: RemoveDraggingHandler
public static void RemoveDraggingHandler(DependencyObject d, DraggingRoutedEventHandler handler)
{
d.SaftyInvoke<UIElement>(uie => uie.RemoveHandler(DraggingEvent, handler));
}
示例3: RemoveSelectedHandler
public static void RemoveSelectedHandler(DependencyObject d, RoutedEventHandler handler)
{
d.SaftyInvoke<UIElement>(uie => uie.RemoveHandler(SelectedEvent, handler));
}
示例4: OnRegisterCommandBindingChanged
private static void OnRegisterCommandBindingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
//sender.SaftyInvoke<UIElement>(el =>
// {
// var bindings = e.NewValue as CommandBindingCollection;
// if (bindings != null)
// el.CommandBindings.AddRange(bindings);
// });
var bindings = e.NewValue as CommandBindingCollection;
if (bindings == null)
return;
sender.SaftyInvoke<UIElement>(el =>
{
if (bindings.Count != el.CommandBindings.Count)
{
foreach (CommandBinding binding in bindings)
{
if (el.CommandBindings.Contains(binding))
continue;
el.CommandBindings.Add(binding);
}
}
});
}
示例5: RemoveEndEditHandler
public static void RemoveEndEditHandler(DependencyObject d, CellEditRoutedEventHandler handler)
{
d.SaftyInvoke<UIElement>(uie => uie.RemoveHandler(EndEditEvent, handler));
}