My First WPF App with code behind : Xaml « Windows Presentation Foundation « C# / C Sharp






My First WPF App with code behind

My First WPF App with code behind
   

<Window x:Class="MyFirstWPFApp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MyFirstWPFApp" Height="336" Width="343">
  <Grid>      
      <Button Click="MyClickEvent" VerticalAlignment="Top" HorizontalAlignment="Left"
         Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="0" Grid.RowSpan="1" Margin="43,61,0,0"
         Width="75" Height="23" Name="btnGo">
        Go
      </Button>

    </Grid>
  
</Window>
//File:Window.xaml.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;


namespace MyFirstWPFApp
{
    public partial class Window1 : System.Windows.Window
    {

        private void MyClickEvent(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("A!", "Message", MessageBoxButton.OK, MessageBoxImage.Hand);
        }

        public Window1()
        {
            InitializeComponent();
        }

    }
}

   
    
    
  








Related examples in the same category

1.Property InheritanceProperty Inheritance
2.Attached PropertiesAttached Properties
3.Property Element SyntaxProperty Element Syntax
4.Embedded Code in Window.xamlEmbedded Code in Window.xaml
5.Xaml Button with namespaceXaml Button with namespace
6.Markup Extensions for ButtonMarkup Extensions for Button
7.Markup Extensions with Property Elements.xamlMarkup Extensions with Property Elements.xaml
8.Inner element with xml namespaceInner element with xml namespace
9.Embedded code for Application
10.Set button properties with Linq styleSet button properties with Linq style
11.Xaml and Code behindXaml and Code behind
12.Use Linq to get control from a containerUse Linq to get control from a container
13.Create Button from Xaml stringCreate Button from Xaml string
14.Reference name defined in Xaml in cs fileReference name defined in Xaml in cs file
15.Insert new line character to xaml attributeInsert new line character to xaml attribute
16.Type loader with Xaml reader