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

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <!--<Button x:Name="Btn1" 
                    Width="200" Height="200"
                    HorizontalAlignment="Left"
                    VerticalAlignment="top"
                    Content="Click ME"
                    ></Button>-->
        </Grid>

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

Blog Archive

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -