How to add textbox control dynamically in runtime in WPF using c#

后端 未结 2 817
猫巷女王i
猫巷女王i 2021-01-29 04:00

I am new in WPF.I want to create 3 textbox for each row at runtime when i click generate button. please help me.

Automatically created textbox

 **Code b         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-29 04:36

    I assume your page's content is a Canvas control:

    Code behind:

    protected void ButtonGenerate_Click(object sender, RoutedEventArgs e)
    {
        TextBox tb = new TextBox();
        (this.Content as Canvas).Children.Add(tb);
    }
    

    You may find other textbox property in https://msdn.microsoft.com/en-us/library/system.windows.controls.textbox(v=vs.110).aspx

提交回复
热议问题