Answer the question
In order to leave comments, you need to log in
How to set the attributes of a button created dynamically?
Visual Studio 2019 WPF XAML
There is working code.
Button btn = new Button();
btn.Height = 80;
btn.Width = 150;
btn.Name = "Button1";
btn.Content = "Click ME";
ActionStackPanel.Children.Add(btn);
//Всё ниже не верно
btn.Click = "Button1_Click";
btn.Click += "Button1_Click";
btn.Margin.Left = 1;
btn.Margin="1,0,0,0";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question