public TwoWayReactivePropertyBinding(IReactiveObject source, ReactiveProperty <T> reactiveProperty) : base( new OneWayReactivePropertyBinding <T, TSource>(source, reactiveProperty), new OneWayToSourceReactivePropertyBinding <T, TSource>(source, reactiveProperty), BindingResolutionMode.Immediate) { }
private static void ItemsSourceChanged( IReactiveObject source, ReactivePropertyChangeEventArgs <IEnumerable> change) { var itemsControl = (ItemsControl)source; if (change.OldValue is INotifyCollectionChanged) { itemsControl.changingItems.Dispose(); } var observableCollection = change.NewValue as INotifyCollectionChanged; if (observableCollection != null) { itemsControl.changingItems = Observable.FromEventPattern <NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>( handler => new NotifyCollectionChangedEventHandler(handler), handler => observableCollection.CollectionChanged += handler, handler => observableCollection.CollectionChanged -= handler).Subscribe( itemsControl.OnNextItemChange); } itemsControl.isItemsSourceNew = true; itemsControl.InvalidateMeasure(); }
private static void OnIsCheckedPropertyChanged( IReactiveObject source, ReactivePropertyChangeEventArgs <bool?> args) { var button = source as ToggleButton; if (button == null) { return; } bool?newValue = args.NewValue; if (newValue == true) { button.OnChecked(); } else if (newValue == false) { button.OnUnchecked(); } else { button.OnIndeterminate(); } }
public IReactiveObject GetMainViewModel(bool createNew = true) { if (createNew) { this.currentMainViewModel = (IReactiveObject)Activator.CreateInstance(this.mainViewModelType.AsType()); } return(this.currentMainViewModel); }
/// <summary> /// Invalidates the sender's Measure layout pass when a <see cref = "ReactiveProperty{T}">ReactiveProperty</see> value is changed. /// </summary> /// <typeparam name = "T">The type of the <see cref = "ReactiveProperty{T}">ReactiveProperty</see>.</typeparam> /// <param name = "sender">The ReactiveObject whose <see cref = "ReactiveProperty{T}">ReactiveProperty</see> has changed.</param> /// <param name = "args">An instance of <see cref = "ReactivePropertyChangeEventArgs{T}">ReactivePropertyChangeEventArgs</see> that carries information about the change.</param> public static void InvalidateMeasure <T>(IReactiveObject sender, ReactivePropertyChangeEventArgs <T> args) { var uiElement = sender as IElement; if (uiElement != null) { uiElement.InvalidateMeasure(); } }
public PropertyHelper(IReactiveObject source, IObservable <TRet> observable, string propertyName) { observable.Subscribe( v => { source.RaisePropertyChanging(propertyName); Value = v; source.RaisePropertyChanged(propertyName); }); }
public static void RaisePropertyChanged <T>(this IReactiveObject reactiveObject, Expression <Func <T> > propertyExpression) { var memberExpr = propertyExpression.Body as MemberExpression; if (memberExpr == null) { throw new ArgumentException("propertyExpression should represent access to a member"); } string memberName = memberExpr.Member.Name; // ReSharper disable once ExplicitCallerInfoArgument reactiveObject.RaisePropertyChanged(memberName); }
private static void ChildPropertyChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs <IElement> change) { var border = (Border)source; border.InvalidateMeasure(); IElement oldChild = change.OldValue; if (oldChild != null) { oldChild.VisualParent = null; } IElement newChild = change.NewValue; if (newChild != null) { newChild.VisualParent = border; } }
private static void ContentPropertyChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs <IElement> change) { var contentControl = (ContentControl)source; contentControl.InvalidateMeasure(); IElement oldContent = change.OldValue; if (oldContent != null) { oldContent.VisualParent = null; } IElement newContent = change.NewValue; if (newContent != null) { newContent.VisualParent = contentControl; } contentControl.OnContentChanged(oldContent, newContent); }
private static void ItemsPanelChanged(IReactiveObject source, ReactivePropertyChangeEventArgs <Panel> change) { var itemsControl = (ItemsControl)source; Panel newPanel = change.NewValue; Panel oldPanel = change.OldValue; if (oldPanel != null) { oldPanel.VisualParent = null; } if (newPanel != null) { if (!(newPanel.Children is ITemplatedList <IElement>)) { throw new NotSupportedException( "ItemsControl requires a panel whose Children collection implements ITemplatedList<IElement>"); } newPanel.VisualParent = itemsControl; } itemsControl.InvalidateMeasure(); }
/// <summary> /// Gets the underlying observable from the IReactiveObject instance. /// </summary> /// <param name="reactiveObject">The reactive object to get the atom for.</param> /// <returns>The IAtom instance to get.</returns> /// <exception cref="ArgumentOutOfRangeException">Thrown when there is no observable object internally.</exception> public static IObservable GetObservable(this IReactiveObject reactiveObject) { return(GetObservable((object)reactiveObject)); }
private static void WidthChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange) { ((TestBindingObject)source).widthPropertyChangedCalledbackCount++; }
public OneWayReactivePropertyBinding(IReactiveObject source, ReactiveProperty <TSourceProp> reactiveProperty) : base(BindingResolutionMode.Immediate) { this.SourceObservable = source.GetObservable <TSourceProp, TSource>(reactiveProperty).Select(Convert); }
private static void ItemsSourceChanged( IReactiveObject source, ReactivePropertyChangeEventArgs<IEnumerable> change) { var itemsControl = (ItemsControl)source; if (change.OldValue is INotifyCollectionChanged) { itemsControl.changingItems.Dispose(); } var observableCollection = change.NewValue as INotifyCollectionChanged; if (observableCollection != null) { itemsControl.changingItems = Observable.FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>( handler => new NotifyCollectionChangedEventHandler(handler), handler => observableCollection.CollectionChanged += handler, handler => observableCollection.CollectionChanged -= handler).Subscribe( itemsControl.OnNextItemChange); } itemsControl.isItemsSourceNew = true; itemsControl.InvalidateMeasure(); }
public static LazyProperty <T> CreateLazy <T>(this IReactiveObject reactive, Expression <Func <T> > nameExpression, Expression <Func <T> > valueExpression) { return(reactive.Reactor.CreateLazy <T>(nameExpression, valueExpression)); }
private static void WidthChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange) { ((TestBindingObject)source).widthPropertyChangedCalledbackCount++; }
private static void ChildPropertyChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs<IElement> change) { var border = (Border)source; border.InvalidateMeasure(); IElement oldChild = change.OldValue; if (oldChild != null) { oldChild.VisualParent = null; } IElement newChild = change.NewValue; if (newChild != null) { newChild.VisualParent = border; } }
public static IEnumerable <T> GetServices <T>(this IReactiveObject @object, string contract = null) { return(Locator.Current.GetServices <T>(contract)); }
private static void WidthChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange) { ((TestBindingObject)source).WidthChangedCallback( reactivePropertyChange.OldValue, reactivePropertyChange.NewValue); }
private static void WidthChangedCallback( IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange) { ((TestBindingObject)source).WidthChangedCallback( reactivePropertyChange.OldValue, reactivePropertyChange.NewValue); }
public static Property <T> Create <T>(this IReactiveObject reactive, string name, Expression <Func <T> > valueExpression) { return(reactive.Reactor.Create <T>(name, valueExpression)); }
/// <summary> /// Raises the <see cref="PropertyChanged"/> event. /// </summary> /// <param name="propertyName"></param> protected void OnPropertyChanged(string propertyName) { IReactiveObject reactive = this as IReactiveObject; reactive.RaisePropertyChanged(propertyName); }
public static Property <T> Create <T>(this IReactiveObject reactive, Expression <Func <T> > nameExpression, T defaultValue = default(T)) { return(reactive.Reactor.Create <T>(nameExpression, defaultValue)); }
public MainWindow(IReactiveObject viewModel, IBackgroundManager backgroundManager) { InitializeComponent(); DataContext = viewModel; backgroundManager.SetBackgroudApp(null, "notepad++"); }
public static Property <T> Create <T>(this IReactiveObject reactive, string name, T defaultValue = default(T)) { return(reactive.Reactor.Create <T>(name, defaultValue)); }
private static void DataContextChanged(IReactiveObject source, ReactivePropertyChangeEventArgs<object> args) { ((UIElement)source).InvalidateMeasureOnDataContextInheritors(); }
private static void DataContextChanged(IReactiveObject source, ReactivePropertyChangeEventArgs <object> args) { ((UIElement)source).InvalidateMeasureOnDataContextInheritors(); }
public OneWayToSourceReactivePropertyBinding(IReactiveObject source, ReactiveProperty <T> reactiveProperty) : base(source.GetObserver <T, TSource>(reactiveProperty)) { }
private static void ItemsPanelChanged(IReactiveObject source, ReactivePropertyChangeEventArgs<Panel> change) { var itemsControl = (ItemsControl)source; Panel newPanel = change.NewValue; Panel oldPanel = change.OldValue; if (oldPanel != null) { oldPanel.VisualParent = null; } if (newPanel != null) { if (!(newPanel.Children is ITemplatedList<IElement>)) { throw new NotSupportedException( "ItemsControl requires a panel whose Children collection implements ITemplatedList<IElement>"); } newPanel.VisualParent = itemsControl; } itemsControl.InvalidateMeasure(); }
private static void OnIsCheckedPropertyChanged( IReactiveObject source, ReactivePropertyChangeEventArgs<bool?> args) { var button = source as ToggleButton; if (button == null) { return; } bool? newValue = args.NewValue; if (newValue == true) { button.OnChecked(); } else if (newValue == false) { button.OnUnchecked(); } else { button.OnIndeterminate(); } }