I'm looking for best practice in order to optimize Xamarin Forms app when switching visibility of layouts in order to show them when screen resizing. Xamarin Forms loads any layout either if IsVisible=false. So, what I'm looking to optimize my app is, load layouts when IsVisible=True, if it turns to False, is there a way to "unload" it so it does not take too much memory of a device? Because there's no problem with UWP, but there are phones with low memory.
Let's suppose I have next code:
<StackLayout IsVisible="False" Orientation="Vertical">
<!-- Make it visible when small screen -->
<CustomView1></CustomView1>
<CustomView2></CustomView2>
</StackLayout>
<StackLayout IsVisible="True" Orientation="Horizontal">
<!-- Make it NON visible when small screen -->
<CustomView1></CustomView1>
<CustomView2></CustomView2>
</StackLayout>
Xamarin would load same views 2 times. What I'm looking is like in web, remove it from the DOM (or dont load it in the DOM until it's visible), but for Xamarin Forms. So the app does not load the view when it does not need it, and I'm looking to have it while runtime, on the window app resize.
PS: It could be done by making use of OnIdiom.Phone, OnIdiom.Tablet and OnIdiom.Desktop, but this last, I could not have the view as desired if UWP window app resize.