|I have a
FrameworkElement (subclass) in my app which is a host for custom
Visuals (my app is a sort of drawing program).
Now I just put the first
UIElement in the visual container. A
UserControl which host a bunch of
Controls, including a
Now when the
Text change and the text box resize and go outside the containing
UserControl, it is clipped and does not show anymore.
I tried to set
false on the
UserControl, didn't help (in fact it was already
Now in my
UIElement I can be aware of the need to resize, thanks to
protected virtual void OnChildDesiredSizeChanged(UIElement child);
But I need to know that in my visual container.
At the moment it looks like it should only really be able to host & resize
UIElement which implement some sort of
INotifyResize interface, which I could inform thanks to this
I wonder if there is already a way I can know that, with just any
UIElement, not just the one made specifically to be hosted by that container.
EDIT / REMARK
5 minutes later... I think I might had answered my own question!
I could just override
OnChildDesiredSizeChanged() in the visual container....
I think there might be some issues, because some
ContainerVisual are involved in the
Visual hierarchy... let's see...
So I tried that and it is really strange
protected override void OnChildDesiredSizeChanged(UIElement child)
child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
child.Arrange(new Rect(BoundedVisual.GetLocation(child), child.DesiredSize));
This method is called only once and the
child didn't resize...
Ha, I see, this didn't work, it this was another child (the one which display the scollbar). got nothing for the text...
EDIT / FOUND a solution
I am using this
UIElement event to do my re
Arrange(), it seems to be working
public event EventHandler LayoutUpdated;
modified 18-Dec-21 7:49am.