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