--- /dev/null
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 40998, "[UWP] Pressing escape with an awaited DisplayActionSheet doesn't return a result", PlatformAffected.WinRT)]
+ public class Bugzilla40998 : TestContentPage
+ {
+ protected override void Init()
+ {
+ var resultLabel = new Label
+ {
+ Text = "ActionSheet Result - use the ActionSheet to show the result"
+ };
+ Content = new StackLayout
+ {
+ Children =
+ {
+ resultLabel,
+ new Button
+ {
+ Text = "Click to display ActionSheet",
+ Command = new Command(async () =>
+ {
+ var result = await DisplayActionSheet("Test ActionSheet", "Cancel", "Destroy", new string[] { "Test Button" });
+ resultLabel.Text = result;
+ })
+ }
+ }
+ };
+ }
+ }
+}
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40333.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla31806.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41078.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla40998.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
using Windows.UI.Xaml.Media.Animation;
#if WINDOWS_UWP
+using Windows.Foundation;
using Windows.Foundation.Metadata;
+using Windows.UI.Core;
using Windows.UI.ViewManagement;
#endif
options.SetResult((string)e.ClickedItem);
};
+ TypedEventHandler<CoreWindow, CharacterReceivedEventArgs> onEscapeButtonPressed = delegate(CoreWindow window, CharacterReceivedEventArgs args)
+ {
+ if (args.KeyCode == 27)
+ {
+ dialog.Hide();
+ options.SetResult(ContentDialogResult.None.ToString());
+ }
+ };
+
+ Window.Current.CoreWindow.CharacterReceived += onEscapeButtonPressed;
+
_actionSheetOptions = options;
if (options.Cancel != null)
options.SetResult(options.Cancel);
else if (result == ContentDialogResult.Primary)
options.SetResult(options.Destruction);
+
+ Window.Current.CoreWindow.CharacterReceived -= onEscapeButtonPressed;
}
#else
void OnPageActionSheet(Page sender, ActionSheetArguments options)