In a WPF app I can move a UserControl
from a ContentControl
to another one in code like this:
myContentControl1.Content = null;
myContentControl2.Content = myUserControl;
The problem is that the UserControl
that has been moved is a rather heavy one (consists of a lot of smaller controls). So the above operation takes a significant amount of time, almost as long as when I load the UserControl
initially. It seems that every element in that UserControl
goes through processing to be moved under another ContentControl
.
Is there a more efficient and faster method of placing a UserControl
under another parent (in my case a ContentControl
) as its child (without the need for UI thread to process all its elements every time)? (Dynamically, in code-behind)