private static void SelectedItem_Changed(
            DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            // Notify any listeners when the selected item changed.
            var  self           = (NavigationView)d;
            bool isSettingsItem = e.NewValue != null &&
                                  e.NewValue == self.SettingsItem;
            var itemChangedArgs = new NavigationViewItemEventArgs(e.NewValue, isSettingsItem);

            self.OnSelectedItemChanged(itemChangedArgs);
        }
        private void ItemsListView_ItemInvoked(object sender, ListViewItemInvokedEventArgs e)
        {
            // We always get a NavigationViewItem in the event args (the clicked item).
            // We want to raise the ItemInvoked event with the "real" item in the MenuItems
            // collection though.
            // -> We need the ItemContainerGenerator to retrieve it.
            var  itemsContainer = (ItemsControl)sender;
            var  item           = itemsContainer.ItemContainerGenerator.ItemFromContainer(e.InvokedItem);
            bool isSettingsItem = SettingsItem != null &&
                                  e.InvokedItem == SettingsItem;

            this.TraceInfo("Menu Item Invoked. Item: {0}", item);
            var eventData = new NavigationViewItemEventArgs(item, isSettingsItem);

            OnItemInvoked(eventData);

            // If the NavigationView is on Overlay-mode, we want to automatically close it.
            if (IsInOverlayMode && AutoCloseOverlayingPane)
            {
                this.TraceVerbose("Collapsing NavigationView, since user invoked item while in Overlay mode.");
                IsPaneOpen = false;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Raises the <see cref="ItemInvoked"/> event
 /// </summary>
 /// <param name="e">Event data for the event.</param>
 protected virtual void OnItemInvoked(NavigationViewItemEventArgs e)
 {
     ItemInvoked?.Invoke(this, e);
 }
Esempio n. 4
0
 /// <summary>
 /// Raises the <see cref="SelectedItemChanged"/> event.
 /// </summary>
 /// <param name="e">Event data for the event.</param>
 protected virtual void OnSelectedItemChanged(NavigationViewItemEventArgs e)
 {
     SelectedItemChanged?.Invoke(this, e);
 }