Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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();
        }
        /// <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();
            }
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange)
 {
     ((TestBindingObject)source).widthPropertyChangedCalledbackCount++;
 }
Ejemplo n.º 8
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange)
 {
     ((TestBindingObject)source).widthPropertyChangedCalledbackCount++;
 }
Ejemplo n.º 9
0
 private static void DataContextChanged(IReactiveObject source, ReactivePropertyChangeEventArgs<object> args)
 {
     ((UIElement)source).InvalidateMeasureOnDataContextInheritors();
 }
Ejemplo n.º 10
0
        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;
            }
        }
Ejemplo n.º 11
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange)
 {
     ((TestBindingObject)source).WidthChangedCallback(
         reactivePropertyChange.OldValue, reactivePropertyChange.NewValue);
 }
Ejemplo n.º 12
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange)
 {
     ((TestBindingObject)source).WidthChangedCallback(
         reactivePropertyChange.OldValue, reactivePropertyChange.NewValue);
 }
Ejemplo n.º 13
0
        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();
        }
Ejemplo n.º 14
0
        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();
        }
Ejemplo n.º 15
-1
        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();
            }
        }