// EXECUTION FUNCTIONS
 public ApplicationButton(ApplicationInfoTO app, ref StackPanel stackPanel, ref DockPanel topBar)
 {
     myApplication      = app;
     settingsStackPanel = stackPanel;
     this.topBar        = topBar;
     Button             = UIManager.CreateApplicationButton(myApplication, new RoutedEventHandler(SetUpSettingsObjects));
 }
        public static Button CreateApplicationButton(ApplicationInfoTO app, RoutedEventHandler buttonEvent)
        {
            // Setup Grid
            var cdef1 = new ColumnDefinition {
                Width = new GridLength(10, GridUnitType.Star)
            };
            var cdef2 = new ColumnDefinition {
                Width = new GridLength(90, GridUnitType.Star)
            };

            var newGrid = new Grid {
                Focusable = false
            };

            newGrid.ColumnDefinitions.Add(cdef1);
            newGrid.ColumnDefinitions.Add(cdef2);

            // Setup Application's Icon
            var newImage = new Image
            {
                Name   = "Image",
                Margin = new Thickness(2),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Source = app.Icon
            };

            // Setup Application's Label
            var newLabel = new Label
            {
                Name                = "Label",
                Content             = app.Name,
                Width               = double.NaN,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Height              = 30,
                FontWeight          = FontWeights.Bold
            };

            // Assign elements to the grid and adjust grid's alignment
            Grid.SetColumn(newImage, 0);
            Grid.SetColumn(newLabel, 1);
            newGrid.Children.Add(newImage);
            newGrid.Children.Add(newLabel);

            // Create the button by using the grid as its content
            var newButton = new Button
            {
                Height = 30,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Content = newGrid,
                Margin  = new Thickness(2)
            };

            newButton.Click += buttonEvent;

            return(newButton);
        }