WPF adding controls dynamically to the grid

Source: Internet
Author: User
private void Window_Loaded (object sender, RoutedEventArgs e)

{

MYGRID.ROWDEFINITIONS.ADD (New RowDefinition ()); Adding rows

MYGRID.ROWDEFINITIONS.ADD (New RowDefinition ()); Adding rows

Button Btn_click = New button (); Create a Button object

Btn_click.name = "Btn_click"; Set Button Name property

Btn_click.width = 100; Set Button width

Btn_click.height = 100; Set Button height

btn_click.content = "button"; Set Button text content

MYGRID.CHILDREN.ADD (Btn_click); Add to Grid Control

Btn_click.setvalue (grid.rowproperty, 0); Sets the row of the grid control where the button resides

Btn_click.setvalue (grid.columnproperty, 0); Sets the column of the grid control where the button resides

Button Btn_click1 = New button (); Create a Button object

Btn_click1.name = "Btn_click1″; Set Button Name property

Btn_click1.width = 100; Set Button width

Btn_click1.height = 100; Set Button height

btn_click1.content = "button"; Set Button text content

MYGRID.CHILDREN.ADD (BTN_CLICK1); Add to Grid Control

Btn_click1.setvalue (Grid.rowproperty, 1); Sets the row of the grid control where the button resides

Btn_click1.setvalue (grid.columnproperty, 0); Sets the column of the grid control where the button resides

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.