diff --git a/WinUIGallery/Controls/PageHeader.xaml b/WinUIGallery/Controls/PageHeader.xaml
index 666e08d54..4602f5902 100644
--- a/WinUIGallery/Controls/PageHeader.xaml
+++ b/WinUIGallery/Controls/PageHeader.xaml
@@ -26,255 +26,184 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Label="About API"
+ ToolTipService.ToolTip="About API">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
+
-
-
+ Content="{x:Bind Title}"
+ NavigateUri="{Binding Uri, FallbackValue=''}"
+ ToolTipService.ToolTip="{Binding Uri}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+
-
-
-
-
-
+ x:Name="ControlSourceLink"
+ Content="{x:Bind Item.Title}"
+ ToolTipService.ToolTip="{x:Bind ControlSourceLink.NavigateUri}" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WinUIGallery/Controls/PageHeader.xaml.cs b/WinUIGallery/Controls/PageHeader.xaml.cs
index b1d4478e2..2fc577f3d 100644
--- a/WinUIGallery/Controls/PageHeader.xaml.cs
+++ b/WinUIGallery/Controls/PageHeader.xaml.cs
@@ -2,10 +2,12 @@
// Licensed under the MIT License.
using System;
-using WinUIGallery.Data;
-using WinUIGallery.Helper;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+using WinUIGallery.Data;
+using WinUIGallery.Helper;
using Uri = System.Uri;
namespace WinUIGallery.DesktopWap.Controls
@@ -43,8 +45,8 @@ public void SetSamplePageSourceLinks(string BaseUri, string PageName)
// Pagetype is not null!
// So lets generate the github links and set them!
var pageName = PageName + ".xaml";
- PageCodeGitHubLink.NavigateUri = new Uri(BaseUri + pageName + ".cs");
PageMarkupGitHubLink.NavigateUri = new Uri(BaseUri + pageName);
+ PageCodeGitHubLink.NavigateUri = new Uri(BaseUri + pageName + ".cs");
}
public void SetControlSourceLink(string BaseUri, string SourceLink)
@@ -63,11 +65,11 @@ public void SetControlSourceLink(string BaseUri, string SourceLink)
private void OnCopyLinkButtonClick(object sender, RoutedEventArgs e)
{
- this.CopyLinkAction?.Invoke();
+ CopyLinkAction?.Invoke();
if (ProtocolActivationClipboardHelper.ShowCopyLinkTeachingTip)
{
- this.CopyLinkButtonTeachingTip.IsOpen = true;
+ CopyLinkButtonTeachingTip.IsOpen = true;
}
}
@@ -80,24 +82,58 @@ public void OnThemeButtonClick(object sender, RoutedEventArgs e)
private void OnCopyDontShowAgainButtonClick(TeachingTip sender, object args)
{
ProtocolActivationClipboardHelper.ShowCopyLinkTeachingTip = false;
- this.CopyLinkButtonTeachingTip.IsOpen = false;
+ CopyLinkButtonTeachingTip.IsOpen = false;
}
private void OnCopyLink()
{
- ProtocolActivationClipboardHelper.Copy(this.Item);
+ ProtocolActivationClipboardHelper.Copy(Item);
}
+
public async void OnFeedBackButtonClick(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/WinUI-Gallery/issues/new/choose"));
}
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ [GeneratedComInterface]
+ [Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public partial interface IDataTransferManagerInterop
+ {
+ IntPtr GetForWindow(in IntPtr appWindow, in Guid riid);
+ void ShowShareUIForWindow(IntPtr appWindow);
+ }
+
+ private static Guid _dtm_iid =
+ new(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);
+
+ public void ShareButton_Click(object sender, RoutedEventArgs e)
{
- if (Item == null || (string.IsNullOrEmpty(Item.ApiNamespace) && Item.BaseClasses == null))
+ // example: https://learn.microsoft.com/windows/apps/develop/ui-input/display-ui-objects#for-classes-that-implement-idatatransfermanagerinterop
+
+ return; // CODE DOESN'T WORK -- GetWindowHandle(this) -- 'this' should equal MainWindow.Xaml.cs
+
+ // Retrieve the window handle (HWND) of the current WinUI 3 window.
+ var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
+
+ IDataTransferManagerInterop interop =
+ Windows.ApplicationModel.DataTransfer.DataTransferManager.As
+ ();
+
+ IntPtr result = interop.GetForWindow(hWnd, riid: in _dtm_iid);
+ var dataTransferManager = WinRT.MarshalInterface
+ .FromAbi(result);
+
+ dataTransferManager.DataRequested += (sender, args) =>
{
- APIDetailsBtn.Visibility = Visibility.Collapsed;
- }
+ args.Request.Data.Properties.Title = "In a desktop app...";
+ args.Request.Data.SetText("...display WinRT UI objects that depend on CoreWindow.");
+ args.Request.Data.RequestedOperation =
+ Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
+ };
+
+ // Show the Share UI
+ interop.ShowShareUIForWindow(hWnd);
}
}
}
diff --git a/WinUIGallery/ItemPage.xaml b/WinUIGallery/ItemPage.xaml
index c172ab707..4ea10d189 100644
--- a/WinUIGallery/ItemPage.xaml
+++ b/WinUIGallery/ItemPage.xaml
@@ -29,11 +29,14 @@
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
-
+
+
+
+
-
+
+
diff --git a/WinUIGallery/ItemPage.xaml.cs b/WinUIGallery/ItemPage.xaml.cs
index 74d95a40c..a828e70ec 100644
--- a/WinUIGallery/ItemPage.xaml.cs
+++ b/WinUIGallery/ItemPage.xaml.cs
@@ -24,8 +24,8 @@ namespace WinUIGallery
///
public sealed partial class ItemPage : Page
{
- private static string WinUIBaseUrl = "https://github.com/microsoft/microsoft-ui-xaml/tree/main/src/controls/dev";
- private static string GalleryBaseUrl = "https://github.com/microsoft/WinUI-Gallery/tree/main/WinUIGallery/ControlPages/";
+ private static readonly string WinUIBaseUrl = "https://github.com/microsoft/microsoft-ui-xaml/tree/main/src/controls/dev";
+ private static readonly string GalleryBaseUrl = "https://github.com/microsoft/WinUI-Gallery/tree/main/WinUIGallery/ControlPages/";
public ControlInfoDataItem Item
{
@@ -49,7 +49,7 @@ public void SetInitialVisuals()
{
pageHeader.ToggleThemeAction = OnToggleTheme;
navigationRootPage.NavigationViewLoaded = OnNavigationViewLoaded;
-
+
this.Focus(FocusState.Programmatic);
}
}
@@ -145,7 +145,7 @@ private void SetControlExamplesTheme(ElementTheme theme)
{
controlExample.RequestedTheme = theme;
}
- if(controlExamples.Count() == 0)
+ if (!controlExamples.Any())
{
this.RequestedTheme = theme;
}