Skip to content

Add SwitchPresenter Control #1908

@michael-hawker

Description

@michael-hawker

I'm submitting a...

Problem

When providing a choice to the user, like picking a check-in method:
image

image

It could be handy to be able to swap out controls with XAML vs having to create separate complex visual states or logic to handle the dynamic UI changes.

image

Solution

The SwitchPresenter control would act as a switch statement for XAML providing a dynamic way to change out content based on some other value.

     <ComboBox x:Name="Lookup" Header="Look up reservation" SelectedIndex="0">
            <x:String>Select an option</x:String>
            <x:String>Confirmation Code</x:String>
            <x:String>E-ticket number</x:String>
            <x:String>Mileage Plan number</x:String>
     </ComboBox>
     <controls:SwitchPresenter Value="{x:Bind Lookup.SelectedItem}">
            <controls:Case Value="Confirmation Code">
                    <TextBox Name="ConfirmationCodeValidator"
                                    extensions:TextBoxRegex.Regex="^[a-zA-Z]{6}$"
                                    Header="Confirmation code"
                                    PlaceholderText="6 letters" />
            </controls:Case>
            <controls:Case Value="E-ticket number">
                    <TextBox Name="TicketValidator"
                                    extensions:TextBoxRegex.Regex="(^\d{10}$)|(^\d{13}$)"
                                    Header="E-ticket number"
                                    PlaceholderText="10 or 13 numbers" />
            </controls:Case>
            <controls:Case Value="Millage Plan number">
                    <TextBox Name="PlanValidator"
                                    Header="Mileage Plan #"
                                    PlaceholderText="Mileage Plan #" />
            </controls:Case>
            <controls:Case IsDefault="True">
            </controls:Case>
     </controls:SwitchPresenter>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions