C # Learning notes for WPF application and Windows Form applications

Source: Internet
Author: User

First, WPF application

WPF uses XAML (Extensible Application Markup Language) to extend the Application Markup Language for page manipulation, which is easy to understand.


The following piece of code is the layout of the page using the XAML language

<window x:class= "Wpfapplication1.window1"
Xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"
Title= "Window1" height= "width=" >
<grid width= "height=" >
<Grid.RowDefinitions>
<rowdefinition height= "/>"
<rowdefinition height= "*"/>
</Grid.RowDefinitions>
<stackpanel >
<textblock text= "Top stack Panel" verticalalignment= "Center"/>
</StackPanel>
<stackpanel >
<textblock text= "Bottom stack Panel" verticalalignment= "Center"/>
</StackPanel>
</Grid>
</Window>

The interface is as follows:

Second, Windows Form applications

In fact, the development of WPF and Windows Form application is very similar to the development of Windows Phone, and it is all about dragging and dropping controls, editing, and reacting to the actions of controls.

Here is an example of a Windows Form applications

UI Design:

The code inside the Form1 is as follows:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacewindowsformsapplication2{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        Private voidButton1_Click (Objectsender, EventArgs e) {            stringA =TextBox1.Text; stringb =TextBox2.Text; if(A = ="Qwer"&& b = ="123456") {MessageBox.Show ("Landing Success"); }            Else{MessageBox.Show ("Login Failed"); TextBox2.Text=" "; }        }        Private voidButton2_Click (Objectsender, EventArgs e) {TextBox2.Text=" "; TextBox1.Text=" "; }    }}

The results are as follows: Login failed:

Login success:

Personally, the development of this kind of application is to learn from the example of the use of a variety of controls, so I cite two examples, the use of the control is much the same, and many of the use of the control need to learn from the actual.

C # Learning notes for WPF application and Windows Form applications

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.