private MenuItem MenuItemFromNavigationPaneItem(NavigationPaneItem item, bool isHiddenItem) { MenuItem menuItem = new MenuItem(); menuItem.IsCheckable = true; Binding b = new Binding(); b.Source = item; if (isHiddenItem) { b.Path = new PropertyPath(Selector.IsSelectedProperty); } else { b.Path = new PropertyPath(NavigationPane.IsItemExcludedProperty); b.Converter = new BooleanNegateConverter(); } b.Mode = BindingMode.TwoWay; menuItem.SetBinding(MenuItem.IsCheckedProperty, b); if (item.ImageSmall != null) { Image image = new Image(); image.Width = 16; image.Height = 16; image.Source = item.ImageSmall; menuItem.Icon = image; } menuItem.Header = XamlHelper.CloneUsingXaml(item.Header, true); return(menuItem); }
private void ResetItems() { Items.Clear(); for (int j = 0; j < navigationPane.Items.Count; j++) { NavigationPaneItem item = navigationPane.Items[j] is NavigationPaneItem ? navigationPane.Items[j] as NavigationPaneItem: navigationPane.ItemContainerGenerator.ContainerFromIndex(j) as NavigationPaneItem; if (item != null) { Items.Add(new NavigationPaneOptionsData(item, XamlHelper.CloneUsingXaml(item.Header, true), !NavigationPane.GetIsItemExcluded(item))); } } }