- Back to Home »
- Windows Phone apps , Windows store apps C#/XAML , WPF »
- Creating XAML Button inside Grid using C# code
Posted by :
Sudhir Chekuri
Tuesday, 5 November 2013
C# Code to create button inside grid
public partial class MainPage : PhoneApplicationPage{
// Constructor
public MainPage()
{
InitializeComponent();
Button Btn1=new Button();
Btn1.Width=200;
Btn1.Height=200;
Btn1.HorizontalAlignment=HorizontalAlignment.Left;
Btn1.VerticalAlignment=VerticalAlignment.Top ;
Btn1.Name = "Btn1";
Btn1.Content="Click ME";
Btn1.Margin = new Thickness(100, 0, 0, 0);
ContentPanel.Children.Add(Btn1);
}
The above C# code is equal to below XAML code