1 / 4

Windows Presentation Foundation

Windows Presentation Foundation. (WPF). XAML & WPF. XAML element corresponds to a WPF class Element's attributes have corresponding property/event in the class. Example , <Button Background="Red"> No </Button> Or use C #: Button btn = new Button();

brede
Download Presentation

Windows Presentation Foundation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Presentation Foundation (WPF)

  2. XAML & WPF • XAML element corresponds to a WPF class • Element's attributes have corresponding property/event in the class. • Example, <Button Background="Red"> No </Button> • Or use C#: Button btn = new Button(); btn.Background= Brushes.Red; btn.Content= "No";

  3. WPF example – part 1 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation " xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SDKSample.AWindow" Title="Window with Button" Width="250" Height="100"> <!-- Add button to window --> <Button Name="button" Click="button_Click">Click Me! </Button> </Window> • x:Class associates • XAML def'n of window (above) • code-behind class (Awindow) on next slide • This example (pars 1 & 2) is from: http://msdn.microsoft.com/en-us/library/aa970268(v=vs.110).aspx

  4. WPF example –part 2 using System.Windows; // Window, RoutedEventArgs, MessageBox namespace SDKSample { public partial class AWindow: Window { public AWindow() { // InitializeComponent call is required to merge the UI  // that is defined in markup with this class, including   // setting properties and registering event handlers InitializeComponent(); } void button_Click(object sender, RoutedEventArgs e) { // Show message box when button is clicked MessageBox.Show("Hello, from WPF app!"); } } }

More Related