diff --git a/components/Primitives/samples/Primitives.Samples.csproj b/components/Primitives/samples/Primitives.Samples.csproj index 220cd303..3927b93a 100644 --- a/components/Primitives/samples/Primitives.Samples.csproj +++ b/components/Primitives/samples/Primitives.Samples.csproj @@ -11,6 +11,7 @@ + diff --git a/components/Primitives/samples/SwitchPresenter.md b/components/Primitives/samples/SwitchPresenter.md index e7ec2938..471de5a6 100644 --- a/components/Primitives/samples/SwitchPresenter.md +++ b/components/Primitives/samples/SwitchPresenter.md @@ -12,7 +12,7 @@ issue-id: 0 icon: Assets/SwitchPresenter.png --- -The `SwitchPresenter` control acts like a switch statement for XAML. It allows a developer to display certain content based on the condition of another value as an alternative to managing multiple Visibility values or complex visual states. +The `SwitchPresenter` control acts like a switch statement for XAML. It allows a developer to display certain content based on the condition of another value as an alternative to managing multiple `Visibility` values or complex visual states. Unlike traditional approaches of showing/hiding components within a page, the `SwitchPresenter` will only load and attach the matching Case's content to the Visual Tree. @@ -25,3 +25,7 @@ SwitchPresenter can make it easier to follow complex layout changes or layouts w Or it can simply be used to clearly display different outcomes based on some state which can be useful for a `NavigationView` or with a simple enum as in the following example: > [!SAMPLE SwitchPresenterValueSample] + +`SwitchPresenter` can also be used as a replacement for the deprecated `Loading` control. This provides more fine-grained control over animations and content within each state: + +> [!SAMPLE SwitchPresenterLoaderSample] diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml new file mode 100644 index 00000000..54a8f50d --- /dev/null +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs new file mode 100644 index 00000000..3619303f --- /dev/null +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace PrimitivesExperiment.Samples.SwitchPresenter; + +[ToolkitSampleBoolOption("LoadingState", true, Title = "IsLoading")] +[ToolkitSample(id: nameof(SwitchPresenterLoaderSample), "SwitchPresenter Loader", description: $"A sample for showing how to use a {nameof(SwitchPresenter)} to show a loading UI when data is loading.")] +public sealed partial class SwitchPresenterLoaderSample : Page +{ + public SwitchPresenterLoaderSample() + { + this.InitializeComponent(); + } +}