public void BuildMainPanel() { MainPanel.Children.Clear(); MenuNodeDictionary.Clear(); foreach (var MenuNode in App.AppConfig.ContextMenuNodes) { var NodeItems = BuildMainPanelItem(MenuNode); if (NodeItems != null) { foreach (var NodeItem in NodeItems) { MainPanel.Children.Add(NodeItem); } } } foreach (var SystemMenuNode in App.SystemMenuNodes) { System.Windows.Controls.Button NewButton = new System.Windows.Controls.Button(); MenuNodeDictionary.Add(NewButton, SystemMenuNode); NewButton.Width = System.Windows.SystemParameters.WorkArea.Width / App.AppConfig.HorizonalTileSize; NewButton.Height = NewButton.Width; NewButton.VerticalContentAlignment = VerticalAlignment.Bottom; NewButton.Content = SystemMenuNode.Name; NewButton.Click += SystemButton_Click; if (SystemMenuNode.IconSource != null) { ImageBrush iconImageBrush = new ImageBrush() { Stretch = Stretch.Uniform, Viewport = new Rect(0.25, 0.25, 0.5, 0.5), ImageSource = SystemMenuNode.IconSource, }; NewButton.Background = iconImageBrush; } else { NewButton.Background = SystemImageBrush; } NewButton.Background.Opacity = 1.0; MainPanel.Children.Add(NewButton); } }