0

I have a Silverlight application that is designed for a certain minimum resolution with layout growing gracefully if more space is available. What I want to do now is easily add some crude support for lower resolutions.

To do that, I introduced ScrollViewer as the layout root - the idea was to show appropriate scrollbars when screen is lower then the fixed minimum so the user can scroll the main layout. The problem is, now the whole layout grows without any bounds and scrollbars appear regardless of screen size.

One solution is to set the content's fixed size equal to the minimum supported size. This, however, kills the graceful growing if screen is larger. Or, I imagine, I could programmatically set the maximum size to what I determine is screen resolution.

Is there any way to do this elegantly in XAML?

Jacek Gorgoń
  • 3,206
  • 1
  • 26
  • 43

1 Answers1

0

Try looking at the MinWidth and MaxWidth properties, as well as MinHeight and MaxHeight. The ScrollViewer also has VerticalScrollbarVisibility and HorizontalScrollbarVisibility which may help. Both of these can be set to Disabled (different to just Hidden), which will set the dimensions of the content accordingly. See here.

I've just looked at a working scrollviewer I put in my application. I didn't specify any width or height on the control that is inside the scrollviewer. I specified HorizontalScrollBarVisibility="Disabled" and I laid out the controls inside a grid inside the scrollviewer. The grid expands to the width available and it scrolls vertically as I wanted it to.

Stephen Hewlett
  • 2,415
  • 1
  • 18
  • 31
  • I am aware of these properties. Thing is, to make it work as described, I'd have to set Max* of the Content to what the user screen is. That's my current best solution, but it requires actual code and not just XAML. – Jacek Gorgoń Oct 15 '12 at 07:38