(Advanced?) Layout question
-
I have a
FrameworkElement
(subclass) in my app which is a host for customVisual
s (my app is a sort of drawing program). Now I just put the firstUIElement
in the visual container. AUserControl
which host a bunch ofControl
s, including aTextBox
. Now when theText
change and the text box resize and go outside the containingUserControl
, it is clipped and does not show anymore. I tried to setClip
tofalse
on theUserControl
, didn't help (in fact it was alreadyfalse
). Now in myUIElement
I can be aware of the need to resize, thanks toprotected 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 ofINotifyResize
interface, which I could inform thanks to thisOnChildDesiredSizeChanged()
method. I wonder if there is already a way I can know that, with just anyUIElement
, 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! :omg: :rolleyes: :-D I could just overrideOnChildDesiredSizeChanged()
in the visual container.... I think there might be some issues, because someContainerVisual
are involved in theVisual
hierarchy... let's see... EDIT2 So I tried that and it is really strangeprotected override void OnChildDesiredSizeChanged(UIElement child) { base.OnChildDesiredSizeChanged(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... EDIT3 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 thisUIElement
event to do my reArrange()
, it seems to be working :)public event EventHandler LayoutUpdated;
A new .NET Serialize