Skip to content

Commit 2d0aade

Browse files
authored
Revert "Move storyboards used to show/hide breadcrumbs to XAML" (#47971)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist This PR reverts #47900: it causes an exception in the Release+AOT build configuration when retrieving a storyboard from XAML resources and casting it to a local field. - [x] Closes: #47970 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
1 parent b02e53d commit 2d0aade

2 files changed

Lines changed: 38 additions & 53 deletions

File tree

src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,6 @@
2323
<MicaBackdrop />
2424
</winuiex:WindowEx.SystemBackdrop>
2525
<Grid x:Name="RootElement">
26-
<Grid.Resources>
27-
<Storyboard x:Key="BreadcrumbFadeInStoryboard">
28-
<DoubleAnimation
29-
Storyboard.TargetName="BreadcrumbContainer"
30-
Storyboard.TargetProperty="Opacity"
31-
To="1"
32-
Duration="0:0:0.25">
33-
<DoubleAnimation.EasingFunction>
34-
<CubicEase EasingMode="EaseOut" />
35-
</DoubleAnimation.EasingFunction>
36-
</DoubleAnimation>
37-
</Storyboard>
38-
<Storyboard x:Key="BreadcrumbFadeOutStoryboard">
39-
<DoubleAnimation
40-
Storyboard.TargetName="BreadcrumbContainer"
41-
Storyboard.TargetProperty="Opacity"
42-
To="0"
43-
Duration="0:0:0.2">
44-
<DoubleAnimation.EasingFunction>
45-
<CubicEase EasingMode="EaseIn" />
46-
</DoubleAnimation.EasingFunction>
47-
</DoubleAnimation>
48-
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BreadcrumbContainer" Storyboard.TargetProperty="Visibility">
49-
<DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="Collapsed" />
50-
</ObjectAnimationUsingKeyFrames>
51-
</Storyboard>
52-
</Grid.Resources>
5326
<Grid.RowDefinitions>
5427
<RowDefinition Height="Auto" />
5528
<RowDefinition Height="*" />

src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/SettingsWindow.xaml.cs

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ public sealed partial class SettingsWindow : WindowEx,
3333
private readonly LocalKeyboardListener _localKeyboardListener;
3434

3535
private readonly NavigationViewItem? _internalNavItem;
36-
private readonly Storyboard _breadcrumbFadeInStoryboard;
37-
private readonly Storyboard _breadcrumbFadeOutStoryboard;
3836

37+
private Storyboard? _breadcrumbStoryboard;
3938
private IReadOnlyList<ExtensionGalleryScreenshotViewModel> _currentScreenshotSet = [];
4039
private ExtensionGalleryScreenshotViewModel? _currentScreenshot;
4140

@@ -54,8 +53,6 @@ public sealed partial class SettingsWindow : WindowEx,
5453
public SettingsWindow()
5554
{
5655
this.InitializeComponent();
57-
_breadcrumbFadeInStoryboard = (Storyboard)RootElement.Resources["BreadcrumbFadeInStoryboard"];
58-
_breadcrumbFadeOutStoryboard = (Storyboard)RootElement.Resources["BreadcrumbFadeOutStoryboard"];
5956
this.ExtendsContentIntoTitleBar = true;
6057
this.SetIcon();
6158
var title = RS_.GetString("SettingsWindowTitle");
@@ -323,30 +320,54 @@ private void RootElement_SizeChanged(object sender, SizeChangedEventArgs e)
323320

324321
private void HideBreadcrumb()
325322
{
326-
if (BreadcrumbContainer.Visibility == Visibility.Collapsed)
323+
_breadcrumbStoryboard?.Stop();
324+
325+
var fadeOut = new DoubleAnimation
327326
{
328-
return;
329-
}
327+
To = 0,
328+
Duration = new Duration(TimeSpan.FromMilliseconds(200)),
329+
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn },
330+
};
331+
Storyboard.SetTarget(fadeOut, BreadcrumbContainer);
332+
Storyboard.SetTargetProperty(fadeOut, "Opacity");
330333

331-
_breadcrumbFadeInStoryboard.Stop();
332-
_breadcrumbFadeOutStoryboard.Stop();
333-
_breadcrumbFadeOutStoryboard.Begin();
334+
_breadcrumbStoryboard = new Storyboard();
335+
_breadcrumbStoryboard.Children.Add(fadeOut);
336+
_breadcrumbStoryboard.Completed += (_, _) =>
337+
{
338+
BreadcrumbContainer.Visibility = Visibility.Collapsed;
339+
BreadcrumbContainer.Opacity = 1;
340+
_breadcrumbStoryboard = null;
341+
};
342+
_breadcrumbStoryboard.Begin();
334343
}
335344

336345
private void ShowBreadcrumb()
337346
{
338-
_breadcrumbFadeInStoryboard.Stop();
339-
_breadcrumbFadeOutStoryboard.Stop();
347+
_breadcrumbStoryboard?.Stop();
348+
_breadcrumbStoryboard = null;
340349

341350
if (BreadcrumbContainer.Visibility == Visibility.Collapsed)
342351
{
343352
BreadcrumbContainer.Opacity = 0;
344353
BreadcrumbContainer.Visibility = Visibility.Visible;
345-
_breadcrumbFadeInStoryboard.Begin();
354+
355+
var fadeIn = new DoubleAnimation
356+
{
357+
To = 1,
358+
Duration = new Duration(TimeSpan.FromMilliseconds(250)),
359+
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut },
360+
};
361+
Storyboard.SetTarget(fadeIn, BreadcrumbContainer);
362+
Storyboard.SetTargetProperty(fadeIn, "Opacity");
363+
364+
_breadcrumbStoryboard = new Storyboard();
365+
_breadcrumbStoryboard.Children.Add(fadeIn);
366+
_breadcrumbStoryboard.Completed += (_, _) => _breadcrumbStoryboard = null;
367+
_breadcrumbStoryboard.Begin();
346368
}
347369
else
348370
{
349-
BreadcrumbContainer.Visibility = Visibility.Visible;
350371
BreadcrumbContainer.Opacity = 1;
351372
}
352373
}
@@ -361,7 +382,7 @@ public void Dispose()
361382
private void NavFrame_OnNavigated(object sender, NavigationEventArgs e)
362383
{
363384
BreadCrumbs.Clear();
364-
var shouldShowBreadcrumb = true;
385+
ShowBreadcrumb();
365386

366387
if (e.SourcePageType == typeof(GeneralPage))
367388
{
@@ -384,14 +405,14 @@ private void NavFrame_OnNavigated(object sender, NavigationEventArgs e)
384405
else if (e.SourcePageType == typeof(ExtensionGalleryPage))
385406
{
386407
NavView.SelectedItem = GalleryPageNavItem;
387-
shouldShowBreadcrumb = false;
408+
HideBreadcrumb();
388409
var pageType = RS_.GetString("Settings_PageTitles_GalleryPage");
389410
BreadCrumbs.Add(new(pageType, pageType));
390411
}
391412
else if (e.SourcePageType == typeof(ExtensionGalleryItemPage) && e.Parameter is ExtensionGalleryItemViewModel galleryExtension)
392413
{
393414
NavView.SelectedItem = GalleryPageNavItem;
394-
shouldShowBreadcrumb = false;
415+
HideBreadcrumb();
395416
var galleryPageType = RS_.GetString("Settings_PageTitles_GalleryPage");
396417
BreadCrumbs.Add(new(galleryPageType, "Gallery"));
397418
BreadCrumbs.Add(new(galleryExtension.Title, galleryExtension));
@@ -420,15 +441,6 @@ private void NavFrame_OnNavigated(object sender, NavigationEventArgs e)
420441
BreadCrumbs.Add(new($"[{e.SourcePageType?.Name}]", string.Empty));
421442
Logger.LogError($"Unknown breadcrumb for page type '{e.SourcePageType}'");
422443
}
423-
424-
if (shouldShowBreadcrumb)
425-
{
426-
ShowBreadcrumb();
427-
}
428-
else
429-
{
430-
HideBreadcrumb();
431-
}
432444
}
433445

434446
private void CloseScreenshotViewerButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)