internal static bool LoadState(FrameworkElement control, Stream stream) { States states = GetCurrentStates(stream); string pId = control.Name; StatesControl ctrl = states.GetControl(pId); if (ctrl != null) { MinimizeHelper minimizeHelper = ((IMinimizeHelped)control).ResizeHelper; control.Visibility = ctrl.Visibility; control.Width = ctrl.Width; minimizeHelper.IsMinimized = ctrl.Minimized; minimizeHelper.ExpandedWidth = ctrl.ExpandedWidth; minimizeHelper.ExpandedDelta = ctrl.ExpandedDelta; minimizeHelper.ResetMinizedSize(); if (control is NavigationPane) { NavigationPane pane = control as NavigationPane; pane.LargeItems = ctrl.Items.LargeItems; IEnumerable <NavigationPaneItem> items = pane.Items.OfType <NavigationPaneItem>(); // if Linq were a girl, I should absolutely marry her var sorted = from data in ( from item in items join sItem in ctrl.Items.Items on item.Name equals sItem.Identifier into itemStates from itemState in itemStates.DefaultIfEmpty() select new { Index = itemState == null ? NavigationPanePanel.GetAbosluteIndex(item) : itemState.Order - 0.5, Exluded = itemState == null ? false : itemState.Excluded, Item = item } ) orderby data.Index select data; List <NavigationPaneItem> orderdItems = new List <NavigationPaneItem>(); foreach (var item in sorted) { NavigationPane.SetIsItemExcluded(item.Item, item.Exluded); orderdItems.Add(item.Item); } pane.Items.Clear(); foreach (NavigationPaneItem item in orderdItems) { pane.Items.Add(item); } } return(true); } return(false); }
internal static void SetActivePanel(DependencyObject obj, NavigationPanePanel value) { obj.SetValue(ActivePanelKey, value); }