-1

When we build Universal app for Windows 10, in order to support multiple resolutions we can use Adaptive triggers.

In this case for each visual state, separate layout is used. If we have 3 sizes to adopt, for each layout must be created, and as a result for most controls there will be multiple duplicates, which are hidden and becoming visible for appropriate visual state.

All these controls will be loaded to memory and waste RAM, which can be dangerous for low memory mobile phones (like lumia 620).

Is it right solution to use separate view for this case?

Update

If someone needs, here are good and very simple articles about element layout reordering form wintellect (AdaptiveTrigger, changing element positions in grid) and galasoft (AdaptiveTrigger, RelativePanel).

Samvel Siradeghyan
  • 3,523
  • 3
  • 30
  • 49
  • You can create different xaml page for different devices, but using same code behind – Nguyen Kien Aug 11 '15 at 08:27
  • Even in that case, for mobile we have screens from 4" to 7" with multiple resolutions, I will need to create separate views for those cases as well. In this case this is no more universal app :) – Samvel Siradeghyan Aug 11 '15 at 08:32
  • It is universal app. You create difference view for difference devices but shared same code behind. Corresponding view will pick at runtime. – Nguyen Kien Aug 11 '15 at 09:10
  • It sounds like you are creating a different control for each layout. Can you not reuse the same controls, but lay them out differently? – Jon G Stødle Aug 11 '15 at 11:01
  • @JonStødle, I just want to know best practices for this cases. Controls are same for all layouts, only their places are different. Imagine app on 4" and 6.5". Elements must be placed differently. – Samvel Siradeghyan Aug 11 '15 at 11:08
  • I would recommend reading up on RelativePanel which let's you rearrange UI elements easily. You can read up on it here: https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.relativepanel.aspx – Jon G Stødle Aug 11 '15 at 13:22
  • Downvoting is a good thing, but it could be more helpful is downvoters says what was wrong with question. It could help to increase quality of new questions. – Samvel Siradeghyan Aug 12 '15 at 06:01

1 Answers1

1

Windows 10 Xaml introduces an attribute x:DeferLoadingStrategy to mark controls to be loaded only when needed. This will let you include all of the controls in the Xaml without loading them into memory unless and until they are actually used. In the mobile case where the device is likely to have only one size actually used (or two for portrait / landscape) the layouts for the other sizes will never load.

For the case where you are using the same controls but just have slightly different positioning I would look at moving them (possibly with RelativePanel), as Jon Stødle suggests in the comments.

If there are bigger changes then I'd look into separate layouts (like you're doing) within the same file or with separate Xaml, but for simple positional changes that's probably overkill.

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54