/// <summary> /// Loads main window layout. /// </summary> private void _LoadLayout() { // create navigation tree _navigationTree = new NavigationTree(); // add categories buttons foreach (INavigationItem item in _navigationTree.NaviationTreeRoot.Children) { if (item.Type == NavigationItemType.Page) continue; // NOTE: skip simple pages if (!item.IsVisible) { // NOTE: support only "Preferences" Debug.Assert(item.Name.Equals("Preferences", StringComparison.OrdinalIgnoreCase)); _preferencesCategory = item; continue; // NOTE: skip items if it not visible } // create new button that will be entry point to the category pages ToggleButton button = new ToggleButton(); button.Tag = item; button.Content = item.Caption; button.AddHandler(ToggleButton.ClickEvent, new RoutedEventHandler(OnCategoryButtonClick)); button.Style = Application.Current.Resources["CategoriesToggleButtonStyle"] as Style; CategoryItem category = (CategoryItem)item; if (category.PageCategory == null) category.PageCategory = (PageCategoryItem)Activator.CreateInstance(category.CategoryType); // set binding to "IsEnabled" property _SetBinding(PageCategoryItem.IS_ENABLED_PROPERTY_NAME, button, category.PageCategory, ToggleButton.IsEnabledProperty); // set binding to "ToooltipText" _SetBinding(PageCategoryItem.TOOLTIP_PROPERTY_NAME, button, category.PageCategory, ToggleButton.ToolTipProperty); CategoriesButtons.AddContentItem(button); } _InitSavedPagesRepository(); }