Skip to content

Commit 2506faa

Browse files
Add basic SwitchPresenter sample to Sample App
1 parent 9bbe69c commit 2506faa

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

Microsoft.Toolkit.Uwp.SampleApp/Microsoft.Toolkit.Uwp.SampleApp.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
<Content Include="Icons\More.png" />
273273
<Content Include="Icons\Notifications.png" />
274274
<Content Include="Icons\Services.png" />
275+
<Content Include="SamplePages\Primitives\SwitchPresenter.png" />
275276
<Content Include="SamplePages\TabbedCommandBar\TabbedCommandBar.png" />
276277
<Content Include="SamplePages\Animations\Effects\FadeBehavior.png" />
277278
<Content Include="SamplePages\ColorPicker\ColorPicker.png" />
@@ -976,6 +977,9 @@
976977
<SubType>Designer</SubType>
977978
<Generator>MSBuild:Compile</Generator>
978979
</Page>
980+
<Content Include="SamplePages\Primitives\SwitchPresenter.bind">
981+
<SubType>Designer</SubType>
982+
</Content>
979983
<Page Include="SamplePages\TilesBrush\TilesBrushPage.xaml">
980984
<Generator>MSBuild:Compile</Generator>
981985
<SubType>Designer</SubType>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<Page
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
7+
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
8+
mc:Ignorable="d">
9+
10+
<StackPanel Padding="16">
11+
<ComboBox x:Name="Lookup" Header="Look up reservation" SelectedIndex="0"
12+
Margin="0,0,0,8">
13+
<x:String>Select an option</x:String>
14+
<x:String>Confirmation Code</x:String>
15+
<x:String>E-ticket number</x:String>
16+
<x:String>Mileage Plan number</x:String>
17+
</ComboBox>
18+
<controls:SwitchPresenter Value="{Binding SelectedItem, ElementName=Lookup}">
19+
<controls:Case Value="Confirmation Code">
20+
<StackPanel>
21+
<TextBox Name="ConfirmationCodeValidator"
22+
ui:TextBoxExtensions.Regex="^[a-zA-Z]{6}$"
23+
Header="Confirmation code"
24+
PlaceholderText="6 letters" />
25+
<TextBlock Visibility="{Binding (ui:TextBoxExtensions.IsValid),ElementName=ConfirmationCodeValidator}">Thanks for entering a valid code!</TextBlock>
26+
</StackPanel>
27+
</controls:Case>
28+
<controls:Case Value="E-ticket number">
29+
<StackPanel>
30+
<TextBox Name="TicketValidator"
31+
ui:TextBoxExtensions.Regex="(^\d{10}$)|(^\d{13}$)"
32+
Header="E-ticket number"
33+
PlaceholderText="10 or 13 numbers" />
34+
<TextBlock Visibility="{Binding (ui:TextBoxExtensions.IsValid),ElementName=TicketValidator}">Thanks for entering a valid code!</TextBlock>
35+
</StackPanel>
36+
</controls:Case>
37+
<controls:Case Value="Mileage Plan number">
38+
<TextBox Name="PlanValidator"
39+
Header="Mileage Plan #"
40+
PlaceholderText="Mileage Plan #" />
41+
</controls:Case>
42+
<controls:Case IsDefault="True">
43+
<TextBlock>Please select a way to lookup your reservation above...</TextBlock>
44+
</controls:Case>
45+
</controls:SwitchPresenter>
46+
</StackPanel>
47+
</Page>
1.18 KB
Loading

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/XamlOnlyPage.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:ani="using:Microsoft.Toolkit.Uwp.UI.Animations"
55
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
6+
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
67
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
78
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
89
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
@@ -34,6 +35,11 @@
3435
<ui:SurfaceDialOptions />
3536
</ui:TextBoxExtensions.SurfaceDialOptions>
3637
</TextBox>
38+
<controls:SwitchPresenter x:Key="SwitchPresenterControl">
39+
<controls:CaseCollection>
40+
<controls:Case IsDefault="True" />
41+
</controls:CaseCollection>
42+
</controls:SwitchPresenter>
3743
</Page.Resources>
3844

3945
<Grid>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/samples.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@
463463
"XamlCodeFile": "/SamplePages/TabbedCommandBar/TabbedCommandBar.bind",
464464
"Icon": "/SamplePages/TabbedCommandBar/TabbedCommandBar.png",
465465
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/TabbedCommandBar.md"
466+
},
467+
{
468+
"Name": "SwitchPresenter",
469+
"Subcategory": "Layout",
470+
"About": "The SwitchPresenter is a ContentPresenter which can allow a developer to mimic a switch statement within XAML.",
471+
"CodeUrl": "https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls.Primitives/SwitchPresenter",
472+
"XamlCodeFile": "/SamplePages/Primitives/SwitchPresenter.bind",
473+
"Icon": "/SamplePages/Primitives/SwitchPresenter.png",
474+
"DocumentationUrl": "https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/controls/SwitchPresenter.md"
466475
}
467476
]
468477
},

0 commit comments

Comments
 (0)