[Unity] Trouble adding framework elements dynamically
Posted: 01 Jan 2015, 04:34
Hi,
I tried to add a ContentPresenter or a ContentControl dynamically at runtime. So I created a new ContentPresenter/Control, set the ContentTemplate and DataContext and added this newly created element to the root panel. Unfortunately I wasn't able to spot the newly added control even in an empty test project. So I tested certain other controls such as StackPanels, Buttons, etc. and only a few controls (StackPanel and TextBlock) appeared, while the TextBox and the Button don't appear.
The next things I tried was to give these controls a fixed size, set the alignment, set a background color, add a custom control template, etc. but nothing seems to work.
Has anyone a clue what I am doing wrong?
Oh, and Happy New Year everyone!
I tried to add a ContentPresenter or a ContentControl dynamically at runtime. So I created a new ContentPresenter/Control, set the ContentTemplate and DataContext and added this newly created element to the root panel. Unfortunately I wasn't able to spot the newly added control even in an empty test project. So I tested certain other controls such as StackPanels, Buttons, etc. and only a few controls (StackPanel and TextBlock) appeared, while the TextBox and the Button don't appear.
The next things I tried was to give these controls a fixed size, set the alignment, set a background color, add a custom control template, etc. but nothing seems to work.
Has anyone a clue what I am doing wrong?
Oh, and Happy New Year everyone!