Skip to content

Instantly share code, notes, and snippets.

@vvolkgang
Last active September 8, 2016 16:45
Show Gist options
  • Save vvolkgang/bc237c64517916431d514b811bfe0670 to your computer and use it in GitHub Desktop.
Save vvolkgang/bc237c64517916431d514b811bfe0670 to your computer and use it in GitHub Desktop.
Custom UserDialogs loader in UWP
public class CustomUserDialogs : UserDialogsImpl
{
private LoadingDialog _loadingDialog;
private LoadingDialog LoadingDialog => _loadingDialog ?? (_loadingDialog = new LoadingDialog());
private IAsyncOperation<ContentDialogResult> _loadingDialogTask;
public override void ShowLoading(string title, MaskType? maskType)
{
if(LoadingDialog.IsEnabled)
LoadingDialog.Hide();
_loadingDialogTask = LoadingDialog.ShowAsync();
}
public override void HideLoading()
{
LoadingDialog.Hide();
}
}
<ContentDialog x:Name="contentDialog"
x:Class="FIX_NAMESPACE.LoadingDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FIX_NAMESPACE"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="#00000000"
>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
BorderThickness="0"
>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ProgressRing Grid.Row="0" IsActive="true" Width="100" Height="100" Foreground="Red"/>
<TextBlock Grid.Row="1" Text="Loading..." FontSize="22" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center"/>
</Grid>
</ContentDialog>
public sealed partial class LoadingDialog : ContentDialog
{
public LoadingDialog()
{
this.InitializeComponent();
Application.Current.Resources["ContentDialogBorderWidth"] = new Thickness(0);
}
}
public class Setup : MvxWindowsSetup
{
public Setup(Frame rootFrame, string suspensionManagerSessionStateKey = null) : base(rootFrame, suspensionManagerSessionStateKey)
{
}
public Setup(IMvxWindowsFrame rootFrame) : base(rootFrame)
{
}
protected override void InitializePlatformServices()
{
base.InitializePlatformServices();
Mvx.RegisterSingleton<IEmailService>(() => new EmailService());
}
protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
{
return new MvxWindowsMultiRegionViewPresenter(rootFrame);
}
protected override IMvxApplication CreateApp()
{
return new Core.App();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment