Click here to Skip to main content
15,897,291 members
Articles / Desktop Programming / WPF

WPF Windows: Code-based layout versus XAML

Rate me:
Please Sign up or sign in to vote.
3.10/5 (14 votes)
12 Aug 20065 min read 68.9K   463   24  
Designing your windows from code has suffered from the introduction of WPF and its XAML. Nevertheless it is possible not to use the descriptive language at all. Lets see how.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Windows
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CodeWindows.CanvasWindow cw = new CodeWindows.CanvasWindow();
            cw.Visibility = System.Windows.Visibility.Visible;    
        }

        private void button2_Click(object sender, EventArgs e)
        {
            CodeWindows.StackPanelWindow sw = new CodeWindows.StackPanelWindow();
            sw.Visibility = System.Windows.Visibility.Visible; 
        }

        private void button3_Click(object sender, EventArgs e)
        {
            CodeWindows.DockPanelWindow dw = new CodeWindows.DockPanelWindow();
            dw.Show(); 
        }

        private void button4_Click(object sender, EventArgs e)
        {
            CodeWindows.GridWindow gw = new CodeWindows.GridWindow();
            gw.Show();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer
Romania Romania
Dragos is currently a student at the Polytechnic University of Bucharest. He likes keeping up to date with new and amazing technologies and he hopes he will one day master the mechanisms behind modern day programming languages so that he can write the best possible code from a performance and maintainability point of view.

He keeps track of the things he learns on a daily basis on his blog, at http://picobit.wordpress.com/ .

Comments and Discussions