Instantiate and use a WrapPanel element in code : WrapPanel « 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 » WrapPanel 
24.58.9.Instantiate and use a WrapPanel element in code
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Threading;

  public class app : System.Windows.Application
  {
        System.Windows.Controls.Button btn1;
        System.Windows.Controls.Button btn2;
        System.Windows.Controls.Button btn3;
        System.Windows.Controls.WrapPanel myWrapPanel = new WrapPanel();
    System.Windows.Window mainWindow = new System.Windows.Window();

    protected override void OnStartup (StartupEventArgs e)
    {
      base.OnStartup (e);
            mainWindow.Title = "WrapPanel Sample";
      
            myWrapPanel.Background = System.Windows.Media.Brushes.Azure;
            myWrapPanel.Orientation = Orientation.Horizontal;
            myWrapPanel.ItemHeight = 25;
            myWrapPanel.ItemWidth = 75;
            myWrapPanel.Width = 150;
            myWrapPanel.HorizontalAlignment = HorizontalAlignment.Left;
            myWrapPanel.VerticalAlignment = VerticalAlignment.Top;

            btn1 = new Button();
            btn1.Content = "Button 1";
            btn2 = new Button();
            btn2.Content = "Button 2";
            btn3 = new Button();
            btn3.Content = "Button 3";

            myWrapPanel.Children.Add(btn1);
            myWrapPanel.Children.Add(btn2);
            myWrapPanel.Children.Add(btn3);

            mainWindow.Content = myWrapPanel;
      mainWindow.Show();
    }
    [System.STAThread()]
    private static void Main ()
    {
      app app = new app ();
      app.Run ();
    }
  }
24.58.WrapPanel
24.58.1.Simple WrapPanelSimple WrapPanel
24.58.2.FlowDirection of WrapPanelFlowDirection of WrapPanel
24.58.3.WrapPanel with BackgroundWrapPanel with Background
24.58.4.Vertical WrapPanel WindowVertical WrapPanel Window
24.58.5.Set item width for WrapPanelSet item width for WrapPanel
24.58.6.Set ItemWidth and ItemHeight for WrapPanelSet ItemWidth and ItemHeight for WrapPanel
24.58.7.WrapPanel and Windows ControlsWrapPanel and Windows Controls
24.58.8.WrapPanel with VerticalAlignmentWrapPanel with VerticalAlignment
24.58.9.Instantiate and use a WrapPanel element in code
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.