Question

I am trying to get the render size of a region via the region manager. The reason for this is each time I add a view to the region I want to make sure it will visually fit, I can get the dimensions of the view I am about to add but I am struggling to find a way of getting the height of the region I am about to add to.

Obviously I want to stay away from the view behind code and accessing the UIElement for the region directly.

Any ideas?

Thanks for your time

Was it helpful?

Solution

You can use

_regionManager.Regions[regionName].Views.ElementAtOrDefault(0);

to get the current view of the region you want to use. Then you can check the DesiredSize property of that view to see what the probable width and height is of that region. I think this should work in normal usage.

The thing is there always needs to be a view in that region. If there isn't you might want to use a dummy view or so.

OTHER TIPS

I'd recommend against trying to do this at all. Instead, I would focus on making the region adaptable to being overfilled (automatic resizing, scrolling, tabs, etc).

There's a lot of unpredictable things that can happen here. For example, there are some controls whose views are determined by their container. The true size of the view that you want to add to the region will not be known until it's actually added to the region, so making this decision will be non-trivial.

I know this doesn't directly answer your question, but hopefully it will be helpful regardless.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top