Put Button onto a Grid : Button « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » ButtonScreenshots 
Put Button onto a Grid
Put Button onto a Grid
  

<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("Elexzandreia the beautiful!""Message", MessageBoxButton.OK, MessageBoxImage.Hand);
        }

        public Window1()
        {
            InitializeComponent();
        }

    }
}

   
    
  
Related examples in the same category
1.Gradient background buttonGradient background button
2.Shaking ButtonShaking Button
3.Default ButtonDefault Button
4.Button with Image sourceButton with Image source
5.Button with OpacityMaskButton with OpacityMask
6.The button and text block are up-side down in the custom coordinate system.The button and text block are up-side down in the custom coordinate system.
7.TextBox as Button ContentTextBox as Button Content
8.Button IsMouseOverButton IsMouseOver
9.Using common TextElement attached properties
10.Button HorizontalAlignment="Center"Button HorizontalAlignment=
11.Fish Eye ButtonsFish Eye Buttons
12.Enlarge Button In XamlEnlarge Button In Xaml
13.Click to rotate a ButtonClick to rotate a Button
14.Click to scale a ButtonClick to scale a Button
15.Change Button Alignment, Margin, FontSize and Padding in Style SettingChange Button Alignment, Margin, FontSize and Padding in Style Setting
16.Gradient Button by RectangleGradient Button by Rectangle
17.Rotated 35 degreesRotated 35 degrees
18.Set VerticalAlignment/HorizontalAlignment for ButtonSet VerticalAlignment/HorizontalAlignment for Button
19.Button with Inline Property TriggerButton with Inline Property Trigger
20.The implementation of our button's Click event handler in XamlThe implementation of our button's Click event handler in Xaml
21.To add a button control and a text block to the canvas
22.Button mouse down eventButton mouse down event
23.Button mouse down previewButton mouse down preview
24.Simple Custom ButtonSimple Custom Button
25.Custom Shaped ButtonCustom Shaped Button
26.Set Delay and Interval for RepeatButtonSet Delay and Interval for RepeatButton
27.A simple template for a round buttonA simple template for a round button
28.Load style defined in Xaml and apply to the ButtonLoad style defined in Xaml and apply to the Button
29.Nested Button contentNested Button content
30.Button PreviewMouseLeftButtonDown action and MouseLeftButtonDown actionButton PreviewMouseLeftButtonDown action and MouseLeftButtonDown action
31.Button PreviewMouseDown action and MouseDown actionButton PreviewMouseDown action and MouseDown action
32.Button click actionButton click action
33.Dynamically add Button to a Grid and add Action listenerDynamically add Button to a Grid and add Action listener
34.Do event based on button nameDo event based on button name
35.Button Click event handlerButton Click event handler
36.Add buttons to a Canvas with codeAdd buttons to a Canvas with code
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.