private void ReorderModules() { LayoutSettings = new global::wenku8.Settings.Layout.BookInfoView(); TOCBg.DataContext = LayoutSettings.GetBgContext( "TOC" ); ViewOrder = LayoutSettings.GetViewOrders(); LayoutRoot.FlowDirection = LayoutSettings.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight ; IEnumerable<UIElement> Modules = MasterContainer.Children.OrderBy( ( x ) => ViewOrder.IndexOf( ( x as Border ).Name ) ); foreach ( UIElement e in Modules ) { Border Mod = e as Border; Logger.Log( ID, "Placing in Order: " + Mod.Name, LogType.DEBUG ); MasterContainer.Children.Remove( e ); if ( ViewOrder.IndexOf( Mod.Name ) != -1 ) { MasterContainer.Children.Add( e ); } } if ( ViewOrder.Count() == 0 ) { SetTemplateNone(); } }