Пример #1
0
        internal static void RegisterForChangeNotification(ChangeNotification notification)
        {
            //Bind to a depedency property
            Binding b = new Binding(notification.PropertyName)
            {
                Source = notification.Source
            };
            DependencyProperty prop = DependencyProperty.RegisterAttached(
                string.Format("ListenAttached_{0}_{1}", notification.PropertyName, Guid.NewGuid().ToString()),
                typeof(object),
                typeof(DependencyObject),
                new PropertyMetadata(notification.Callback));

            notification.Target = notification.Target ?? notification.Source;
            BindingOperations.SetBinding(notification.Target, prop, b);

            if (GetChangeNotifications(notification.Target) == null)
            {
                SetChangeNotifications(notification.Target, new List <ChangeNotification>());
            }

            List <ChangeNotification> changeNotifications = GetChangeNotifications(notification.Target);

            changeNotifications.Add(notification);
        }
Пример #2
0
        private void updatePage(int newPageIndex, int oldPageIndex)
        {
            if (newPageIndex > -1)
            {
                WizardPage newPage = Pages[newPageIndex];

                // Register for change notification on the InputValid property of the new wizard page
                List <ChangeNotification> notifications = DependencyPropertyHelper.GetChangeNotifications(this);
                bool notificationRegistered             = false;
                if (notifications != null)
                {
                    foreach (ChangeNotification notification in notifications)
                    {
                        if (notification.Source.Equals(newPage) && notification.Callback == InputValid_PropertyChanged &&
                            notification.PropertyName == "InputValid")
                        {
                            notificationRegistered = true;
                            break;
                        }
                    }
                }

                if (!notificationRegistered)
                {
                    ChangeNotification notification = new ChangeNotification()
                    {
                        Source       = newPage,
                        PropertyName = "InputValid",
                        Target       = this,
                        Callback     = InputValid_PropertyChanged
                    };
                    DependencyPropertyHelper.RegisterForChangeNotification(notification);
                }

                checkCommandsCanExecute();
            }

            CurrentPageIndex = newPageIndex;

            if (PageChanged != null)
            {
                PageChanged(this, EventArgs.Empty);
            }
        }
        internal static void RegisterForChangeNotification(ChangeNotification notification)
        {
            //Bind to a depedency property
            Binding b = new Binding(notification.PropertyName) { Source = notification.Source };
            DependencyProperty prop = DependencyProperty.RegisterAttached(
                string.Format("ListenAttached_{0}_{1}", notification.PropertyName, Guid.NewGuid().ToString()),
                typeof(object),
                typeof(DependencyObject),
                new PropertyMetadata(notification.Callback));

            notification.Target = notification.Target ?? notification.Source;
            BindingOperations.SetBinding(notification.Target, prop, b);

            if (GetChangeNotifications(notification.Target) == null)
                SetChangeNotifications(notification.Target, new List<ChangeNotification>());

            List<ChangeNotification> changeNotifications = GetChangeNotifications(notification.Target);
            changeNotifications.Add(notification);
        }
        private void updatePage(int newPageIndex, int oldPageIndex)
        {
            if (newPageIndex > -1)
            {
                WizardPage newPage = Pages[newPageIndex];

                // Register for change notification on the InputValid property of the new wizard page
                List<ChangeNotification> notifications = DependencyPropertyHelper.GetChangeNotifications(this);
                bool notificationRegistered = false;
                if (notifications != null)
                {
                    foreach (ChangeNotification notification in notifications)
                    {
                        if (notification.Source.Equals(newPage) && notification.Callback == InputValid_PropertyChanged
                        && notification.PropertyName == "InputValid")
                        {
                            notificationRegistered = true;
                            break;
                        }
                    }
                }

                if (!notificationRegistered)
                {
                    ChangeNotification notification = new ChangeNotification()
                    {
                        Source = newPage,
                        PropertyName = "InputValid",
                        Target = this,
                        Callback = InputValid_PropertyChanged
                    };
                    DependencyPropertyHelper.RegisterForChangeNotification(notification);
                }

                checkCommandsCanExecute();
            }

            CurrentPageIndex = newPageIndex;

            if (PageChanged != null)
                PageChanged(this, EventArgs.Empty);
        }