Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom showmode example in flyout page #1133

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions WinUIGallery/ControlPages/FlyoutPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
Expand Down Expand Up @@ -50,5 +50,41 @@
</x:String>
</local:ControlExample.Xaml>
</local:ControlExample>

<local:ControlExample HeaderText="Flyout with different ShowMode">
<local:ControlExample.Example>
<Button Content="Click for flyout">
<Button.Flyout>
<Flyout x:Name="CustomFlyout" ShowMode="{x:Bind ShowMode, Mode=OneWay}">
<TextBlock Text="This is a flyout"/>
</Flyout>
</Button.Flyout>
</Button>
</local:ControlExample.Example>

<local:ControlExample.Options>
<ComboBox x:Name="FlyoutShowModeBox" Header="ShowMode" SelectedIndex="0" SelectionChanged="FlyoutShowModeBox_SelectionChanged">
<x:String>Auto</x:String>
<x:String>Standard</x:String>
<x:String>Transient</x:String>
<x:String>TransientWithDismissOnPointerMoveAway</x:String>
</ComboBox>
</local:ControlExample.Options>

<local:ControlExample.Xaml>
<x:String xml:space="preserve">
&lt;Button Content="Click for flyout"&gt;
&lt;Button.Flyout&gt;
&lt;Flyout ShowMode="$(ShowMode)"&gt;
&lt;TextBlock Text="This is a flyout" /&gt;
&lt;/Flyout&gt;
&lt;/Button.Flyout&gt;
&lt;/Button&gt;
</x:String>
</local:ControlExample.Xaml>
<local:ControlExample.Substitutions>
<local:ControlExampleSubstitution Key="ShowMode" Value="{x:Bind CustomFlyout.ShowMode, Mode=OneWay}"/>
</local:ControlExample.Substitutions>
</local:ControlExample>
</StackPanel>
</Page>
</Page>
26 changes: 25 additions & 1 deletion WinUIGallery/ControlPages/FlyoutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//*********************************************************
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
Expand Down Expand Up @@ -28,5 +28,29 @@ private void DeleteConfirmation_Click(object sender, RoutedEventArgs e)
f.Hide();
}
}

private FlyoutShowMode _showMode = FlyoutShowMode.Auto;
public FlyoutShowMode ShowMode
{
get => _showMode;
set
{
CustomFlyout.ShowMode = value;
_showMode = value;
}
}

private void FlyoutShowModeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
switch (e.AddedItems[0].ToString())
{
case "Auto": ShowMode = FlyoutShowMode.Auto; break;
case "Standard": ShowMode = FlyoutShowMode.Standard; break;
case "Transient": ShowMode = FlyoutShowMode.Transient; break;
default: ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway;
break;
}

}
}
}