using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace WpfBlankProjShalvin
{
class Class1 : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new Class1 { Title = "Shalvin", WindowStartupLocation = WindowStartupLocation.CenterScreen, Width = 300, Height = 200 });
}
}
}
WPF StackPanel and Button Click
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1
{
class Class1 : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new Class1());
}
StackPanel stp;
Button btn;
public Class1()
{
stp = new StackPanel();
this.Content = stp;
btn = new Button { Content = "Shalvin" };
btn.Click += new RoutedEventHandler(btn_Click);
stp.Children.Add(btn);
}
private void btn_Click(Object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello");
}
}
}
Grid RowDefinition
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace WpfGrid
{
class Class1 : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new Class1());
}
Grid grd;
TextBlock tbl;
RowDefinition rd;
public Class1()
{
grd = new Grid { ShowGridLines = true };
this.Content = grd;
rd = new RowDefinition ();
grd.RowDefinitions.Add(rd);
rd = new RowDefinition();
grd.RowDefinitions.Add(rd);
tbl = new TextBlock { Text = "Name" };
grd.Children.Add(tbl);
}
}
}
No comments:
Post a Comment