コード例 #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);
            }
        }
コード例 #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);
            }
        }