Create controls dynamically in WPF

Asked

Viewed 80 times

1

I need to create checklists that depend on previous inputs and processing. How do I create these "checklists" dynamically in WPF? (a code snippet, please).

1 answer

2


CheckBox ch1 = new CheckBox();
ch1.Location = new Point(10, 10);
ch1.Text = "Olá Mundo!";
this.Controls.Add(ch1);

See if you solve, also enter your default options, for example if you want it to come checked already, etc.

  • I’m not finding a method that fits with this.Controls.Add(ch1)

  • this is the name of the form you are in, in which case the row adds the component in this form.It appears that error?

  • The Controls class is not available from "this" (I had already read something similar in another topic, but I think this class is only from windows Forms).

  • try adding a panel and adding inside it panelnome.Children.Add(ch1);

  • Ok. It worked. I hope the panel expands depending on the number of checklists.

  • anything comments there that we try to solve ^^

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.