<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\Xamarin.Forms.Platform.UAP.xr.xml" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
<file src="..\Xamarin.Forms.Platform\bin\$Configuration$\netstandard2.0\Xamarin.Forms.Platform.dll" target="lib\uap10.0" />
<file src="..\Xamarin.Forms.Platform.UAP\Properties\Xamarin.Forms.Platform.UAP.rd.xml" target="lib\uap10.0\Xamarin.Forms.Platform.UAP\Properties" />
+
+ <file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\FormsFlyout.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\FormsCommandBarStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\FormsProgressBarStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\Resources.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
--- /dev/null
+<UserControl
+ x:Class="Xamarin.Forms.Platform.UWP.FormsFlyout"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:local="using:Xamarin.Forms.Platform.UAP"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d"
+ d:DesignHeight="300"
+ d:DesignWidth="400">
+
+ <UserControl.Resources>
+ <ResourceDictionary>
+ <Style x:Key="ActionTitle" TargetType="TextBlock" BasedOn="{StaticResource SubtitleTextBlockStyle}">
+ <Setter Property="FontSize" Value="18"/>
+ <Setter Property="MaxLines" Value="2"/>
+ </Style>
+
+ <Style x:Key="ActionButton" TargetType="Button">
+ <Setter Property="Height" Value="32" />
+ <Setter Property="HorizontalAlignment" Value="Stretch" />
+ <Setter Property="Margin" Value="5,0,0,0" />
+ </Style>
+
+ <Style x:Key="LeftActionButton" TargetType="Button" BasedOn="{StaticResource ActionButton}">
+ <Setter Property="Margin" Value="0,0,5,0"/>
+ </Style>
+
+ <Style x:Key="ActionSheetList" TargetType="ListView">
+ <Setter Property="Margin" Value="0,10,0,10"/>
+ <Setter Property="IsItemClickEnabled" Value="true"/>
+ <Setter Property="SelectionMode" Value="None" />
+ <Setter Property="ItemContainerStyle">
+ <Setter.Value>
+ <Style TargetType="ListViewItem">
+ <Setter Property="Margin" Value="0" />
+ <Setter Property="HorizontalContentAlignment" Value="Stretch" />
+ </Style>
+ </Setter.Value>
+ </Setter>
+ <Setter Property="ItemTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <TextBlock Text="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="16" />
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+ </ResourceDictionary>
+ </UserControl.Resources>
+
+ <Grid Padding="10">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="auto"/>
+ </Grid.RowDefinitions>
+
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="auto"/>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+
+ <TextBlock x:Name="TitleBlock" Style="{StaticResource ActionTitle}"/>
+ <ListView x:Name="OptionsList" Grid.Row="1"
+ Style="{StaticResource ActionSheetList}"
+ ItemClick="ListItemSelected" />
+
+ </Grid>
+
+ <Grid Grid.Row="1" VerticalAlignment="Bottom">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="*"/>
+ </Grid.ColumnDefinitions>
+
+ <Button x:Name="LeftBtn" Grid.Column="0"
+ Style="{StaticResource LeftActionButton}"
+ Click="ActionButtonClicked"/>
+ <Button x:Name="RightBtn" Grid.Column="1"
+ Style="{StaticResource ActionButton}"
+ Click="ActionButtonClicked"/>
+ </Grid>
+ </Grid>
+</UserControl>
--- /dev/null
+using System;
+using System.Linq;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Xamarin.Forms.Internals;
+
+namespace Xamarin.Forms.Platform.UWP
+{
+ public sealed partial class FormsFlyout : UserControl
+ {
+ ActionSheetArguments options;
+ public event EventHandler OptionSelected;
+
+ public FormsFlyout(ActionSheetArguments sheetOptions)
+ {
+ this.InitializeComponent();
+
+ options = sheetOptions;
+
+ TitleBlock.Text = options.Title ?? string.Empty;
+ OptionsList.ItemsSource = options.Buttons.ToList();
+
+ if (options.Cancel != null)
+ {
+ RightBtn.Content = options.Cancel;
+
+ if (options.Destruction != null)
+ LeftBtn.Content = options.Destruction;
+ }
+ else if (options.Destruction != null)
+ RightBtn.Content = options.Destruction;
+
+ LeftBtn.Visibility = LeftBtn.Content == null ? Visibility.Collapsed : Visibility.Visible;
+ RightBtn.Visibility = RightBtn.Content == null ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ void ListItemSelected (object sender, ItemClickEventArgs e)
+ {
+ var selection = (string)e.ClickedItem;
+ options.SetResult(selection);
+
+ OptionSelected?.Invoke(this, null);
+ }
+
+ void ActionButtonClicked(object sender, RoutedEventArgs e)
+ {
+ var button = (Windows.UI.Xaml.Controls.Button)sender;
+ var selection = (string)button.Content;
+ options.SetResult(selection);
+
+ OptionSelected?.Invoke(this, null);
+ }
+ }
+}
if (last != null)
_toolbarTracker.Target = last;
}
-
- static async void OnPageAlert(object sender, AlertArguments options)
- {
- string content = options.Message ?? options.Title ?? string.Empty;
-
- MessageDialog dialog;
- if (options.Message == null || options.Title == null)
- dialog = new MessageDialog(content);
- else
- dialog = new MessageDialog(options.Message, options.Title);
-
- if (options.Accept != null)
- {
- dialog.Commands.Add(new UICommand(options.Accept));
- dialog.DefaultCommandIndex = 0;
- }
-
- if (options.Cancel != null)
- {
- dialog.Commands.Add(new UICommand(options.Cancel));
- dialog.CancelCommandIndex = (uint)dialog.Commands.Count - 1;
- }
-
- if (Device.IsInvokeRequired)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- IUICommand command = await dialog.ShowAsyncQueue();
- options.SetResult(command.Label == options.Accept);
- });
- }
- else
- {
- IUICommand command = await dialog.ShowAsyncQueue();
- options.SetResult(command.Label == options.Accept);
- }
- }
- }
-
- // refer to http://stackoverflow.com/questions/29209954/multiple-messagedialog-app-crash for why this is used
- // in order to allow for multiple MessageDialogs, or a crash occurs otherwise
- public static class MessageDialogExtensions
- {
- static TaskCompletionSource<MessageDialog> _currentDialogShowRequest;
-
- public static async Task<IUICommand> ShowAsyncQueue(this MessageDialog dialog)
- {
- while (_currentDialogShowRequest != null)
- {
- await _currentDialogShowRequest.Task;
- }
-
- TaskCompletionSource<MessageDialog> request = _currentDialogShowRequest = new TaskCompletionSource<MessageDialog>();
- IUICommand result = await dialog.ShowAsync();
- _currentDialogShowRequest = null;
- request.SetResult(dialog);
-
- return result;
- }
}
}
\ No newline at end of file
((ToolbarProvider)_toolbarProvider).CommandBar.Content = page.Title;
}
- static async void OnPageActionSheet(object sender, ActionSheetArguments options)
- {
- List<string> buttons = options.Buttons.ToList();
+ static void OnPageActionSheet(object sender, ActionSheetArguments options)
+ {
+ bool userDidSelect = false;
+ var flyoutContent = new FormsFlyout(options);
- var list = new Windows.UI.Xaml.Controls.ListView
+ var actionSheet = new Flyout
{
- Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetList"],
- ItemsSource = buttons,
- IsItemClickEnabled = true
+ FlyoutPresenterStyle = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["FormsFlyoutPresenterStyle"],
+ Placement = Windows.UI.Xaml.Controls.Primitives.FlyoutPlacementMode.Full,
+ Content = flyoutContent
};
- var dialog = new ContentDialog
+ flyoutContent.OptionSelected += (s, e) =>
{
- Template = (Windows.UI.Xaml.Controls.ControlTemplate)Windows.UI.Xaml.Application.Current.Resources["MyContentDialogControlTemplate"],
- Content = list,
- Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["ActionSheetStyle"]
+ userDidSelect = true;
+ actionSheet.Hide();
};
- if (options.Title != null)
- dialog.Title = options.Title;
-
- list.ItemClick += (s, e) =>
+ actionSheet.Closed += (s, e) =>
{
- dialog.Hide();
- options.SetResult((string)e.ClickedItem);
+ if (!userDidSelect)
+ options.SetResult(null);
};
- TypedEventHandler<CoreWindow, CharacterReceivedEventArgs> onEscapeButtonPressed = delegate (CoreWindow window, CharacterReceivedEventArgs args)
+ actionSheet.ShowAt(((Page)sender).GetOrCreateRenderer().ContainerElement);
+ }
+
+ static async void OnPageAlert(Page sender, AlertArguments options)
+ {
+ string content = options.Message ?? string.Empty;
+ string title = options.Title ?? string.Empty;
+
+ var alertDialog = new ContentDialog
{
- if (args.KeyCode == 27)
- {
- dialog.Hide();
- options.SetResult(ContentDialogResult.None.ToString());
- }
+ Content = content,
+ Title = title
};
- Window.Current.CoreWindow.CharacterReceived += onEscapeButtonPressed;
-
if (options.Cancel != null)
- dialog.SecondaryButtonText = options.Cancel;
+ alertDialog.SecondaryButtonText = options.Cancel;
- if (options.Destruction != null)
- dialog.PrimaryButtonText = options.Destruction;
+ if (options.Accept != null)
+ alertDialog.PrimaryButtonText = options.Accept;
+
+ ContentDialogResult result = await alertDialog.ShowAsync();
- ContentDialogResult result = await dialog.ShowAsync();
if (result == ContentDialogResult.Secondary)
- options.SetResult(options.Cancel);
+ options.SetResult(false);
else if (result == ContentDialogResult.Primary)
- options.SetResult(options.Destruction);
-
- Window.Current.CoreWindow.CharacterReceived -= onEscapeButtonPressed;
+ options.SetResult(true);
}
void ClearCommandBar()
<Path Data="M 50.7361,983.661 C 44.1895,983.661 38.8369,988.97 38.8369,995.517 39.8649,1003.3 45.246,1008.1 49.8547,1014.12 50.2838,1014.66 51.2336,1014.66 51.6619,1014.12 52.1384,1013.48 52.7575,1012.73 53.4248,1011.91 55.0322,1012.07 56.4727,1012.32 57.5676,1012.71 58.407,1013 59.06,1013.33 59.4192,1013.63 59.7784,1013.93 59.7716,1014.11 59.7716,1014.16 59.7716,1014.21 59.7716,1014.39 59.4192,1014.69 59.06,1014.99 58.407,1015.32 57.5676,1015.61 55.8888,1016.2 53.4519,1016.63 50.7361,1016.63 48.0204,1016.63 45.5399,1016.2 43.8611,1015.61 43.0218,1015.32 42.3695,1014.99 42.0103,1014.69 41.6504,1014.39 41.6135,1014.21 41.6135,1014.16 41.6135,1014.11 41.6511,1013.93 42.0103,1013.63 42.3695,1013.33 43.0218,1013 43.8611,1012.71 44.3158,1012.55 44.8455,1012.35 45.4039,1012.22 L 43.8611,1010.33 C 43.6124,1010.4 43.3441,1010.46 43.1119,1010.55 42.1005,1010.9 41.2318,1011.31 40.5555,1011.87 39.8799,1012.43 39.3216,1013.22 39.3216,1014.16 39.3216,1015.1 39.8799,1015.85 40.5555,1016.41 41.2318,1016.97 42.1005,1017.42 43.1119,1017.77 45.1356,1018.48 47.8025,1018.92 50.7362,1018.92 54.437,1018.81 57.9892,1018.36 60.8733,1016.41 62.5084,1014.79 62.0756,1013.4 60.8733,1011.87 60.1969,1011.31 59.3726,1010.9 58.3612,1010.55 57.4331,1010.22 56.3503,1009.94 55.1878,1009.75 56.1992,1008.51 57.2362,1007.18 58.2289,1005.79 60.5599,1002.51 62.5918,998.968 62.5918,995.517 62.5918,988.97 57.2836,983.661 50.7362,983.661 Z M 50.7361,989.655 C 47.571,989.655 44.9627,992.219 44.9627,995.385 44.9627,998.55 47.571,1001.16 50.7361,1001.16 53.902,1001.16 56.4659,998.55 56.4659,995.385 56.4659,992.219 53.902,989.655 50.7361,989.655 Z M 50.7361,991.947 C 52.6591,991.947 54.174,993.462 54.174,995.385 54.174,997.307 52.6591,998.866 50.7361,998.866 48.8139,998.866 47.2546,997.307 47.2546,995.385 47.2546,993.462 48.8139,991.947 50.7361,991.947 Z" Fill="#000000" Height="74" Stretch="Fill" Margin="0" Width="50"/>
</DataTemplate>
- <Style x:Key="PageTitleStyle" TargetType="TextBlock">
+ <Style x:Key="PageTitleStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Setter Property="Background" Value="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
</Style>
- <Style x:Key="ActionSheetStyle" TargetType="ContentDialog" />
- <Style x:Key="ActionSheetList" TargetType="ListView">
- <Setter Property="SelectionMode" Value="None" />
- <Setter Property="ItemContainerStyle">
- <Setter.Value>
- <Style TargetType="ListViewItem">
- <Setter Property="Margin" Value="0" />
- <Setter Property="HorizontalContentAlignment" Value="Stretch" />
- </Style>
- </Setter.Value>
- </Setter>
- <Setter Property="ItemTemplate">
- <Setter.Value>
- <DataTemplate>
- <TextBlock Text="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Style="{ThemeResource SubtitleTextBlockStyle}" />
- </DataTemplate>
- </Setter.Value>
- </Setter>
- </Style>
-
- <ControlTemplate TargetType="ContentDialog" x:Key="MyContentDialogControlTemplate">
- <Border x:Name="Container">
- <Grid x:Name="LayoutRoot">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- </Grid.ColumnDefinitions>
- <Border x:Name="BackgroundElement"
- Background="{TemplateBinding Background}"
- FlowDirection="{TemplateBinding FlowDirection}"
- BorderThickness="{ThemeResource ContentDialogBorderWidth}"
- BorderBrush="{ThemeResource SystemControlForegroundAccentBrush}"
- MaxWidth="{TemplateBinding MaxWidth}"
- MaxHeight="{TemplateBinding MaxHeight}"
- MinWidth="{TemplateBinding MinWidth}"
- MinHeight="{TemplateBinding MinHeight}" >
- <Grid x:Name="DialogSpace" VerticalAlignment="Stretch">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <ScrollViewer x:Name="ContentScrollViewer"
- HorizontalScrollBarVisibility="Disabled"
- VerticalScrollBarVisibility="Disabled"
- ZoomMode="Disabled"
- Margin="{ThemeResource ContentDialogContentScrollViewerMargin}"
- IsTabStop="False">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <!--CHANGED HERE. Used to be Auto as well-->
- <RowDefinition />
- </Grid.RowDefinitions>
- <ContentControl x:Name="Title"
- Margin="{ThemeResource ContentDialogTitleMargin}"
- Content="{TemplateBinding Title}"
- ContentTemplate="{TemplateBinding TitleTemplate}"
- FontSize="20"
- FontFamily="Segoe UI"
- FontWeight="Normal"
- Foreground="{TemplateBinding Foreground}"
- HorizontalAlignment="Left"
- VerticalAlignment="Top"
- IsTabStop="False"
- MaxHeight="{ThemeResource ContentDialogTitleMaxHeight}" >
- <ContentControl.Template>
- <ControlTemplate TargetType="ContentControl">
- <ContentPresenter
- Content="{TemplateBinding Content}"
- MaxLines="2"
- TextWrapping="Wrap"
- ContentTemplate="{TemplateBinding ContentTemplate}"
- Margin="{TemplateBinding Padding}"
- ContentTransitions="{TemplateBinding ContentTransitions}"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- </ControlTemplate>
- </ContentControl.Template>
- </ContentControl>
- <ContentPresenter x:Name="Content"
- ContentTemplate="{TemplateBinding ContentTemplate}"
- Content="{TemplateBinding Content}"
- FontSize="{ThemeResource ControlContentThemeFontSize}"
- FontFamily="{ThemeResource ContentControlThemeFontFamily}"
- Margin="{ThemeResource ContentDialogContentMargin}"
- Foreground="{TemplateBinding Foreground}"
- Grid.Row="1"
- TextWrapping="Wrap" />
- </Grid>
- </ScrollViewer>
- <Grid x:Name="CommandSpace" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
- <Grid.ColumnDefinitions>
- <ColumnDefinition/>
- <ColumnDefinition/>
- </Grid.ColumnDefinitions>
- <Border x:Name="Button1Host"
- Margin="{ThemeResource ContentDialogButton1HostMargin}"
- MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
- MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
- Height="{ThemeResource ContentDialogButtonHeight}"
- HorizontalAlignment="Stretch" />
- <Border x:Name="Button2Host"
- Margin="{ThemeResource ContentDialogButton2HostMargin}"
- MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
- MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
- Height="{ThemeResource ContentDialogButtonHeight}"
- Grid.Column="1"
- HorizontalAlignment="Stretch" />
- </Grid>
- </Grid>
- </Border>
- </Grid>
- </Border>
- </ControlTemplate>
+ <Style x:Key="FormsFlyoutPresenterStyle" TargetType="FlyoutPresenter">
+ <Setter Property="MaxHeight" Value="300"/>
+ <Setter Property="MaxWidth" Value="350"/>
+ <Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundAccentBrush}"/>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="FlyoutPresenter">
+ <Border Background="{TemplateBinding Background}"
+ BorderBrush="{TemplateBinding BorderBrush}"
+ BorderThickness="{TemplateBinding BorderThickness}"
+ VerticalAlignment="Center">
+ <ContentPresenter Content="{TemplateBinding Content}"
+ ContentTemplate="{TemplateBinding ContentTemplate}"
+ ContentTransitions="{TemplateBinding ContentTransitions}"
+ Margin="{TemplateBinding Padding}"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="Top" />
+ </Border>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
<Style x:Key="JumpListGrid" TargetType="GridView">
<Setter Property="ItemTemplate">
</Setter>
</Style>
-
<Style x:Key="FormsListViewItem" TargetType="ListViewItem">
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Compile Include="ViewExtensions.cs" />
<Compile Include="LayoutExtensions.cs" />
<Compile Include="Flags.cs" />
+ <Compile Include="FormsFlyout.xaml.cs">
+ <DependentUpon>FormsFlyout.xaml</DependentUpon>
+ </Compile>
<Compile Include="FormsPresenter.cs" />
<Compile Include="FormsUWP.cs" />
<Compile Include="IToolBarForegroundBinder.cs" />
<Generator>MSBuild:Compile</Generator>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Page>
+ <Page Include="FormsFlyout.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="FormsProgressBarStyle.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>