C # after-school mini-Test 7

Source: Internet
Author: User

WPF (Windows Presentation Foundation)

WPF is the user interface framework, the biggest feature is the separation of design and programming, so that professionals more focused, without distraction.

We can manipulate it through the--xaml language of the XML transformation language.

XAML consists of some rules that tell the parser and compiler how to handle XML, and some keywords, but it doesn't have any meaningful elements of its own.

Look at the following code

<window x:class= "Hellowpf.window1"
xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml" >
    <Window.Title>Window1</Window.Title>
    <Window.Height>300</Window.Height>
    <Window.Width>300</Window.Width>
    <Grid>

</Grid>
</Window>

This code will output the hellowpf.window1

where "http://schemas.microsoft.com/winfx/2006/xaml/presentation" is the namespace that is used to validate itself and child elements. We can declare additional XML namespaces (on the root element or child elements), but the identifiers under each namespace must have a unique prefix.

In C # we can use System.Console.WriteLine ("hellowpf.window1") to achieve the same effect, when you must be surprised, since C # looks simpler, why should we use XAML?

The fact is that with XAML statements, we can quickly view the XAML in IE and see a live button in the browser window, while the C # code has to be used by additional code compilers.

Build and event handling large order: in runtime (run-time) mode, before you set properties for any of the XAML-declared objects, you always add some event handlers so that an event can be triggered when the property is set, without worrying about the order in which the XAML uses the attribute.

Attribute element:

XAML language:

<button xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation" >
<Button.Content>
<rectangle height= "width=" fill= "Black"/>
</Button.Content>
</Button>

In C #:

System.Windows.Controls.Button B = new System.Windows.Controls.Button ();
System.Windows.Shapes.Rectangle r = new System.Windows.Shapes.Rectangle ();
R.width = 40;
R.height = 40;
R.fill = System.Windows.Media.Brushes.Black;
B.content = R;

We can use attribute elements instead of setting properties.

C # after-school mini-Test 7

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.