Ejemplo n.º 1
0
        /// <summary>
        /// Delegate called when the notification count property changed.
        /// </summary>
        /// <param name="pObject">The modified object.</param>
        /// <param name="pEventArgs">The event arguments.</param>
        private static void OnNotificationCountChanged(DependencyObject pObject, DependencyPropertyChangedEventArgs pEventArgs)
        {
            NotificationCountRenderer lControl = pObject as NotificationCountRenderer;

            if (lControl != null)
            {
                // Updating the content.
                int lCount = (int)pEventArgs.NewValue;
                lControl.UpdateRendering(lCount);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Delegate called when the data context property changed.
        /// </summary>
        /// <param name="pObject">The modified object.</param>
        /// <param name="pEventArgs">The event arguments.</param>
        private static void OnDataContextChanged(DependencyObject pObject, DependencyPropertyChangedEventArgs pEventArgs)
        {
            NotificationCountRenderer lControl   = pObject as NotificationCountRenderer;
            NotifierViewModel         lViewModel = pEventArgs.NewValue as NotifierViewModel;

            if (lControl != null && lViewModel != null)
            {
                Binding lNotificationCountBinding = new Binding("Notifications.Count");
                lNotificationCountBinding.Source = lViewModel;
                lControl.SetBinding(NotificationCountProperty, lNotificationCountBinding);

                lControl.UpdateRendering(lViewModel.Notifications.Count);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Method called when the template of the control is applied.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            this.mNotificationCountRenderer = this.GetTemplateChild(PART_NOTIFICATION_COUNT_RENDERER) as NotificationCountRenderer;

            if (this.mNotificationCountRenderer == null)
            {
                throw new ArgumentException("The NotifierButton template is not valid.");
            }

            this.mNotificationCountRenderer.DataContext = this.ViewModel;

            this.UpdateState(this.NotificationCount, this.NotificationCount);
        }