From 6fda9fd6b959ae4a5586876aba661eb627841a16 Mon Sep 17 00:00:00 2001 From: eriklimakc Date: Thu, 30 Nov 2023 16:38:22 +0000 Subject: [PATCH] chore: Adding remarks to ResponsiveView doc --- doc/controls/ResponsiveView.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/controls/ResponsiveView.md b/doc/controls/ResponsiveView.md index 76bf66142..2190efd82 100644 --- a/doc/controls/ResponsiveView.md +++ b/doc/controls/ResponsiveView.md @@ -7,6 +7,29 @@ uid: Toolkit.Controls.ResponsiveView The `ResponsiveView` provides the ability to display different content based on screen size, making it easy to adapt to various devices. +## Remarks + +The ResponsiveView Control adapts to different screen sizes by dynamically choosing the right template. It looks at the current screen width and the defined templates. Since not all templates need a value, the control ensures a smooth user experience by picking the smallest defined template that satisfies the width requirements. If no match is found, it defaults to the largest defined template. + +**Initialization**: The `ResponsiveHelper` needs to be hooked up to the window's `SizeChanged` event in order for it to receive updates when the window size changes. +This is typically done in the `OnLaunched` method in the `App` class, where you can get the current window and call the `HookupEvent` method on the `ResponsiveHelper`. + +Here is an example of how this might be achieved: + +```cs +protected override void OnLaunched(LaunchActivatedEventArgs args) +{ +#if NET6_0_OR_GREATER && WINDOWS && !HAS_UNO + MainWindow = new Window(); +#else + MainWindow = Microsoft.UI.Xaml.Window.Current; +#endif + // ... + var helper = Uno.Toolkit.UI.ResponsiveHelper.GetForCurrentView(); + helper.HookupEvent(MainWindow); +} +``` + ## Inheritance Object → DependencyObject → UIElement → FrameworkElement → Control → ContentControl