question

patricktalon38 avatar image
0 Votes"
patricktalon38 asked ·

Does handling the SizeChanged event, rather than using Adaptive Triggers, have disadvantages?

I've been managing adaptive layout and sizing of my containers and controls to react to smaller app window sizes by way of handling the main pages' SizeChanged event, rather than write a great deal of XAML code to achieve the same results with Adaptive Triggers. The UWP documentation provides in-depth guidance on using Adaptive Triggers, which seems to be an involved way of handling SizeChanged events. Are there advantages of using Adaptive Triggers instead of simply handling app window size change events with conditional logic checking for minimum or maximum widths and heights?

uwpuwp-xaml
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Does my reply make sense?

0 Votes 0 · ·

I haven't heard from you these days. Have you found out which to use?

0 Votes 0 · ·

1 Answer

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered ·

Hello!

Welcome to the Microsoft Q&A!

In my understanding, AdaptiveTrigger Class is a way to handle the size change of the window. The adaptive trigger is a XAML approach and it is cleaner and nicer than the code approach.

You need to be careful when you are handling the SizeChanged event. The element must be visible and it won't trigger the event if it is not visible or collapsed. Another thing you need to pay attention to is that the SizeChanged event might cause a LayoutCycleException if you changed the size of the element self inside the event.

I would use Adaptive Trigger as the first choice when I need to change the element's size according to the window. Only if there are some things that Adaptive Trigger is not able to do, then I will consider the SizeChanged event as the second choice.

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.