-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
640a7b5
commit 98cf554
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
WindowsAppSDKGallery/SamplePages/DialogSamples/MessageDialogPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Page | ||
x:Class="WindowsAppSDKGallery.SamplePages.DialogSamples.MessageDialogPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:WindowsAppSDKGallery.SamplePages.DialogSamples" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:controls="using:WindowsAppSDKGallery.Controls" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
<StackPanel> | ||
|
||
<controls:ApiExample | ||
HeaderText="Content-only dialog" | ||
x:Name="ContentOnly" | ||
Api="new MessageDialog($content).ShowAsync();" | ||
ExecuteApi="ContentOnly_ExecuteApi"/> | ||
|
||
<controls:ApiExample | ||
HeaderText="Title and content dialog" | ||
x:Name="TitleAndContent" | ||
Api="new MessageDialog($content, $title).ShowAsync();" | ||
ExecuteApi="TitleAndContent_ExecuteApi"/> | ||
|
||
</StackPanel> | ||
</Page> |
62 changes: 62 additions & 0 deletions
62
WindowsAppSDKGallery/SamplePages/DialogSamples/MessageDialogPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Popups; | ||
using WindowsAppSDKGallery.Helpers; | ||
|
||
// To learn more about WinUI, the WinUI project structure, | ||
// and more about our project templates, see: http://aka.ms/winui-project-info. | ||
|
||
namespace WindowsAppSDKGallery.SamplePages.DialogSamples | ||
{ | ||
/// <summary> | ||
/// An empty page that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class MessageDialogPage : Page | ||
{ | ||
public MessageDialogPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
/// <summary> | ||
/// Sets the HWND for the dialog so it can be displayed. | ||
/// </summary> | ||
/// <param name="dialog"></param> | ||
/// <returns></returns> | ||
private MessageDialog InitWindow(MessageDialog dialog) | ||
{ | ||
WinRT.Interop.InitializeWithWindow.Initialize(dialog, WindowHelper.GetHwndForCurrentWindow()); | ||
return dialog; | ||
} | ||
|
||
private async void ContentOnly_ExecuteApi(object sender, Controls.ExecuteApiArgs e) | ||
{ | ||
ContentOnly.IsEnabled = false; | ||
|
||
await InitWindow(new MessageDialog(e.Parameters["content"])).ShowAsync(); | ||
|
||
ContentOnly.IsEnabled = true; | ||
} | ||
|
||
private async void TitleAndContent_ExecuteApi(object sender, Controls.ExecuteApiArgs e) | ||
{ | ||
TitleAndContent.IsEnabled = false; | ||
|
||
await InitWindow(new MessageDialog(e.Parameters["content"], e.Parameters["title"])).ShowAsync(); | ||
|
||
TitleAndContent.IsEnabled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters