When LastChildFill property of a DockPanel is set true, the last child added occupies the entire unused space.
That works well, until I had to programmatically replace the last child:
UIElementCollection children = myDockPanel.Children;
UIElement uie = new myBestControl();
children.RemoveAt(children.Count - 1);
children.Add(uie);
Now, the newly added control no longer fill the space.
How should I fix the problem?