SlideServe
Menu
Preferences
© SlideServe · v2026

Introduction to WPF and XAML: Creating a Simple Button Application

brede avatar
4 slides · 221 Views · 40 likes · Oct 15, 2014

This tutorial introduces Windows Presentation Foundation (WPF) and XAML by demonstrating how to create a simple button application. You'll learn how XAML elements correspond to WPF classes, with attributes directly mapping to properties and events in the class. An example is provided on creating a button with a red background and a click event that displays a message box. The tutorial also covers the basics of XAML code structure, including namespaces and the association with code-behind classes, ensuring a solid foundation for WPF development.

Introduction to WPF and XAML: Creating a Simple Button Application - slide 1
01 / 4Introduction to WPF and XAML: Creating a Simple Button Application
1 / 17

Download Presentation

Introduction to WPF and XAML: Creating a Simple Button Application
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

More Related Content

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!"); } } }