Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. (Advanced?) Layout question

(Advanced?) Layout question

Scheduled Pinned Locked Moved WPF
questioncsharpcomgraphicsdocker
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Super Lloyd
    wrote on last edited by
    #1

    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 TextBox. 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 Clip to false on the UserControl, didn't help (in fact it was already false). 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 OnChildDesiredSizeChanged() method. 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! :omg: :rolleyes: :-D 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... EDIT2 So I tried that and it is really strange

        protected 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 this UIElement event to do my reArrange(), it seems to be working :)

        public event EventHandler LayoutUpdated;
    

    A new .NET Serialize

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups