コード例 #1
0
ファイル: NotifierButton.cs プロジェクト: mastertnt/XRay
 /// <summary>
 /// Delegate called when a notification is closed.
 /// </summary>
 /// <param name="pSource">The source view model.</param>
 /// <param name="pEventArgs">The event arguments.</param>
 private void OnViewModelNotificationClosed(NotifierViewModel pSource, NotificationClosedEventArgs pEventArgs)
 {
     this.Dispatcher.Invoke((Action) delegate
     {
         if (this.NotificationClosed != null)
         {
             this.NotificationClosed(this, pEventArgs);
         }
     });
 }
コード例 #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);
            }
        }