Why following code (thanks to Aybe) hangs at line var result = await dialog1.ShowAsync();
I was expecting it to get a simple user input and continue after user clicks OK. But the dialog UI does not even completely shows up. It just hangs with all white background. I just see on top of main window there is a small dialog window with white background and it just hangs there.
I've seen solutions to such issues such as here. But as this solution suggests I'm using async
on Button_Click event. The difference between the referenced solution and mine is that I'm using UWP
and they are probably not. So, what I may be missing and how we can resolve the issue?
private async void myButton_ClickAsync(object sender, RoutedEventArgs e)
{
var dialog1 = new ContentDialog1();
var result = await dialog1.ShowAsync(); //hangs here
if (result == ContentDialogResult.Primary)
{
var text = dialog1.Text;
}
....
....
}
Custom Dialog class:
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace App1
{
public sealed partial class ContentDialog1 : ContentDialog
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof (string), typeof (ContentDialog1), new PropertyMetadata(default(string)));
public ContentDialog1()
{
InitializeComponent();
}
public string Text
{
get { return (string) GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
}
}
UPDATE:
I'm using latest versions of both VS2017
and Windows 10 Professional
Laptop. No tapping (touch device) or smart phone or tablet is involved.