How to dynamically add controls to a window

2 posts, 0 answers
  1. Simon Allport
    Simon Allport avatar
    32 posts
    Member since:
    Aug 2009

    Posted 10 Jan 2011 Link to this post

    I want to be to be able to add textbox to the a rad window that is generated dynamically, but i can't see anything that will allow me to do this.
    I was expecting to see some thing like ' Window.Child.Add();'

    Can anyone help please?

    RadWindow[] window = new RadWindow[5];
                   for (int i = 0; i < 5; i++)
                   {
                       window[i] = new RadWindow();
                          
                       window[i].Width = 250;
                       window[i].Height = 250;
                       window[i].Name = "Apples" + i;
                       window[i].Show();
                   }
  2. Simon Allport
    Simon Allport avatar
    32 posts
    Member since:
    Aug 2009

    Posted 10 Jan 2011 Link to this post

    Hi,
    I found out how to do it. Using the 'Content' property.

    Canvas canvas = new Canvas();
                       canvas.Width = 250;
                       canvas.Height = 250;
                       canvas.Name = "NoteCanvas";
                       Grid notegrid = new Grid();
                       TextBox txtbxNotes = new TextBox();
                       txtbxNotes.Text = "test" + i;
                       notegrid.Children.Add(txtbxNotes);
                       canvas.Children.Add(notegrid);
                       
                   
                       window[i] = new RadWindow();
                       window[i].Width = 250;
                       window[i].Height = 250;
                       window[i].Name = "Apples" + i;
                       window[i].Content = canvas;
                       window[i].Show();

    Thanks

    Simon
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top