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

PatrickTalon38 41 Reputation points

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?

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Roy Li - MSFT 28,241 Reputation points Microsoft Vendor


    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.