Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions WinUIGallery/Pages/ItemPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Linq;
Expand Down Expand Up @@ -64,6 +65,8 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)

if (pageType != null)
{
// Attach Navigated event to add RepositionThemeTransition after navigation
contentFrame.Navigated += ContentFrame_Navigated;
var pageName = string.IsNullOrEmpty(group.Folder) ? pageType.Name : $"{group.Folder}/{pageType.Name}";
pageHeader.SetControlSourceLink(WinUIBaseUrl, item.SourcePath);
pageHeader.SetSamplePageSourceLinks(GalleryBaseUrl, pageName);
Expand All @@ -82,6 +85,38 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
base.OnNavigatedTo(e);
}

private void ContentFrame_Navigated(object sender, NavigationEventArgs e)
{
if (e.Content is Page loadedPage)
{
// Add RepositionThemeTransition to the root Panel of the loaded page
if (loadedPage.Content is Panel panel)
{
if (panel.ChildrenTransitions == null)
{
panel.ChildrenTransitions = new TransitionCollection();
}

// Insure we don't add duplicate RepositionThemeTransition
bool hasReposition = false;
foreach (var t in panel.ChildrenTransitions)
{
if (t is RepositionThemeTransition)
{
hasReposition = true;
break;
}
}

if (!hasReposition)
{
panel.ChildrenTransitions.Add(new RepositionThemeTransition());
}
}
}
contentFrame.Navigated -= ContentFrame_Navigated; // Cleanup event handler
}

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
SetControlExamplesTheme(ThemeHelper.ActualTheme);
Expand Down
4 changes: 0 additions & 4 deletions WinUIGallery/Samples/ControlPages/StoragePickersPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
mc:Ignorable="d">

<StackPanel>
<StackPanel.ChildrenTransitions>
<RepositionThemeTransition/>
</StackPanel.ChildrenTransitions>

<InfoBar IsClosable="False" IsOpen="True" Margin="0,8,0,0">
<RichTextBlock Margin="0,12,12,12" IsTextSelectionEnabled="False">
<Paragraph>
Expand Down