public IOptionsExpression <T> To(DependencyObject target) { BinderExpression.ExposeContext(this, c => { c.TargetObject = target; }); return(this); }
public IOptionsExpression <T> On(DependencyProperty property) { BinderExpression.ExposeContext(this, c => { c.TargetProperty = property; }); return(this); }
private void ConfigureBinding <TBinding>( Action <TBinding> configurationAction ) where TBinding : BindingBase { BinderExpression.ExposeContext(this, c => { TBinding casted = c.Binding as TBinding; if (casted == null) { throw new InvalidOperationException(ExceptionTexts.OperationInvalidForBindingType); } configurationAction(casted); }); }
public static IOptionsExpression <T> KeyGesture <T>( this IOptionsExpression <T> expression, Key key, ModifierKeys modifiers = ModifierKeys.None ) where T : ICommand { KeyGesture gesture = CustomKeyGesture.Create(key, modifiers); InputBinding binding = new KeyBinding { Gesture = gesture }; BinderExpression.ExposeContext( expression, ctx => { BindingOperations.SetBinding(binding, KeyBinding.CommandProperty, ctx.Binding); var targetUIElement = ctx.TargetObject as UIElement; var targetContentElement = ctx.TargetObject as ContentElement; if (targetUIElement != null) { targetUIElement.InputBindings.Add(binding); } else if (targetContentElement != null) { targetContentElement.InputBindings.Add(binding); } else { throw new NotSupportedException(); } } ); return(expression); }