Adding GroupBox to Window : GroupBox « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » GroupBox 
24.54.3.Adding GroupBox to Window
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

    public class MainClass : Window
    {
        [STAThread]
        public static void Main()
        {
            Application app = new Application();
            app.Run(new MainClass());
        }
        public MainClass()
        {
            SizeToContent = SizeToContent.WidthAndHeight;

            GroupBox group = new GroupBox();
            group.Header = "Window Style";
            group.Margin = new Thickness(96);
            group.Padding = new Thickness(5);
            Content = group;

            StackPanel stack = new StackPanel();
            group.Content = stack;

            RadioButton radio = new RadioButton();
            radio.Content = "No border or caption";
            radio.Tag = WindowStyle.None;
            radio.Margin = new Thickness(5);
            stack.Children.Add(radio);

            radio = new RadioButton();
            radio.Content = "Single-border window";
            radio.Tag = WindowStyle.SingleBorderWindow;
            radio.Margin = new Thickness(5);
            radio.IsChecked = (WindowStyle.SingleBorderWindow == WindowStyle);
            stack.Children.Add(radio);

            AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(RadioOnChecked));
        }
        void RadioOnChecked(object sender, RoutedEventArgs args)
        {
            RadioButton radio = args.Source as RadioButton;
            WindowStyle = (WindowStyle)radio.Tag;
        }
    }
24.54.GroupBox
24.54.1.GroupBox DemoGroupBox Demo
24.54.2.GroupBox Header with mixed contentGroupBox Header with mixed content
24.54.3.Adding GroupBox to Window
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.