Exemplo n.º 1
0
        /// <summary>
        /// Initializes an instance of the <see cref="NotifierButton"/> class.
        /// </summary>
        public NotifierButton()
        {
            this.ViewModel = new NotifierViewModel(this);
            this.ViewModel.NotificationClosed += this.OnViewModelNotificationClosed;

            // Scroller is the main control of the drop down window.
            NotificationScroller lScroller = new NotificationScroller();

            lScroller.DataContext = this.ViewModel;

            Binding lNotificationCountBinding = new Binding("Notifications.Count");

            lNotificationCountBinding.Source = this.ViewModel;
            this.SetBinding(NotificationCountProperty, lNotificationCountBinding);

            this.DropDownContent = lScroller;

            this.UpdateState(this.NotificationCount, this.NotificationCount);
        }
Exemplo 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)
        {
            NotificationScroller lControl = pObject as NotificationScroller;

            if (lControl != null)
            {
                Binding lContentBinding = new Binding("DisplayedNotification");
                lContentBinding.Source = pEventArgs.NewValue;
                lControl.SetBinding(ContentProperty, lContentBinding);

                Binding lMessageViewHeightBinding = new Binding("MessageViewHeight");
                lMessageViewHeightBinding.Source = pEventArgs.NewValue;
                lControl.SetBinding(MessageViewHeightProperty, lMessageViewHeightBinding);

                Binding lMessageViewWidthBinding = new Binding("MessageViewWidth");
                lMessageViewWidthBinding.Source = pEventArgs.NewValue;
                lControl.SetBinding(MessageViewWidthProperty, lMessageViewWidthBinding);
            }
        }