Skip to content

Commit

Permalink
chore: Adding remarks to ResponsiveView doc
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Dec 4, 2023
1 parent 33be355 commit a6ed6d4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions doc/controls/ResponsiveView.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a6ed6d4

Please sign in to comment.