Skip to content

Commit

Permalink
Update to WinAppSDK 1.4.1 and remove menu theme workaround (microsoft…
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottj1s authored Sep 20, 2023
1 parent 9c80909 commit 398af50
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 35 deletions.
6 changes: 3 additions & 3 deletions WinUIGallery/ControlPages/MenuBarPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
XamlSource="MenuBar\MenuBarSample1.txt">
<StackPanel>
<TextBlock x:Name="SelectedOptionText" Text="" />
<MenuBar LayoutUpdated="MenuBar_LayoutUpdated" x:Name="Example1">
<MenuBar x:Name="Example1">
<MenuBarItem Title="File">
<MenuFlyoutItem x:Name="o1" Text="New" Click="OnElementClicked"/>
<MenuFlyoutItem x:Name="o2" Text="Open" Click="OnElementClicked"/>
Expand All @@ -38,7 +38,7 @@
XamlSource="Menubar\MenuBarSample3.txt">
<StackPanel>
<TextBlock x:Name="SelectedOptionText1" Text="" />
<MenuBar LayoutUpdated="MenuBar_LayoutUpdated" x:Name="Example2">
<MenuBar x:Name="Example2">
<MenuBarItem Title="File">
<MenuFlyoutItem x:Name ="t2" Text="New" Click="OnElementClicked">
<MenuFlyoutItem.KeyboardAccelerators>
Expand Down Expand Up @@ -101,7 +101,7 @@
XamlSource="MenuBar\MenuBarSample2.txt">
<StackPanel>
<TextBlock x:Name="SelectedOptionText2" Text="" />
<MenuBar LayoutUpdated="MenuBar_LayoutUpdated" x:Name="Example3">
<MenuBar x:Name="Example3">
<MenuBarItem Title="File">
<MenuFlyoutSubItem Text="New">
<MenuFlyoutItem x:Name="z1" Text="Plain Text Document" Click="OnElementClicked"/>
Expand Down
14 changes: 2 additions & 12 deletions WinUIGallery/ControlPages/MenuBarPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AppUIBasics.Helper;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -39,15 +38,6 @@ private void OnElementClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e
{
SelectedOptionText2.Text = "You clicked: " + (sender as MenuFlyoutItem).Text;
}
}

// Workaround for known issue with menu themes in WinAppSDK 1.4 (#8678, #8756)
private void MenuBar_LayoutUpdated(object sender, object e)
{
foreach (var popup in VisualTreeHelper.GetOpenPopupsForXamlRoot(this.XamlRoot))
{
popup.RequestedTheme = ThemeHelper.RootTheme;
}
}
}
}
}
12 changes: 6 additions & 6 deletions WinUIGallery/ControlPages/MenuFlyoutPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
Expand All @@ -19,7 +19,7 @@
<StackPanel x:Name="Control1" Orientation="Horizontal">
<AppBarButton Icon="Sort" IsCompact="True" ToolTipService.ToolTip="Sort" AutomationProperties.Name="Sort">
<Button.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened">
<MenuFlyout>
<MenuFlyoutItem Text="By rating" Click="MenuFlyoutItem_Click" Tag="rating" />
<MenuFlyoutItem Text="By match" Click="MenuFlyoutItem_Click" Tag="match" />
<MenuFlyoutItem Text="By distance" Click="MenuFlyoutItem_Click" Tag="distance" />
Expand All @@ -46,7 +46,7 @@
HeaderText="A MenuFlyout with ToggleMenuFlyoutItems and MenuFlyoutSeparator.">
<Button x:Name="Control2" Content="Options">
<Button.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened">
<MenuFlyout>
<MenuFlyoutItem Text="Reset" />
<MenuFlyoutSeparator />
<ToggleMenuFlyoutItem x:Name="RepeatToggleMenuFlyoutItem" Text="Repeat" IsChecked="True" />
Expand Down Expand Up @@ -76,7 +76,7 @@
<local:ControlExample x:Name="Example3" HeaderText="A MenuFlyout with cascading menus.">
<Button x:Name="Control3" Content="File Options">
<Button.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened">
<MenuFlyout>
<MenuFlyoutItem Text="Open" />
<MenuFlyoutSubItem Text="Send to">
<MenuFlyoutItem Text="Bluetooth" />
Expand Down Expand Up @@ -115,7 +115,7 @@
HeaderText="A MenuFlyout with icons.">
<Button x:Name="Control4" Content="Edit Options">
<Button.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened">
<MenuFlyout>
<MenuFlyoutItem Text="Share">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE72D;" />
Expand Down Expand Up @@ -154,7 +154,7 @@
HeaderText="A MenuFlyout with icons and Keyboard Accelerators." FontFamily="Segoe UI" Loaded="Example5_Loaded">
<Button x:Name="Control5" Content="Edit Options">
<Button.Flyout>
<MenuFlyout Opened="MenuFlyout_Opened">
<MenuFlyout>
<MenuFlyoutItem Text="Share">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xE72D;" />
Expand Down
15 changes: 2 additions & 13 deletions WinUIGallery/ControlPages/MenuFlyoutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//*********************************************************
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
Expand All @@ -7,12 +7,10 @@
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
using AppUIBasics.Helper;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;

namespace AppUIBasics.ControlPages
{
Expand Down Expand Up @@ -47,15 +45,6 @@ private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
private void Example5_Loaded(object sender, RoutedEventArgs e)
{

}

// Workaround for known issue with menu themes in WinAppSDK 1.4 (#8678, #8756)
private void MenuFlyout_Opened(object sender, object e)
{
foreach (var popup in VisualTreeHelper.GetOpenPopupsForXamlRoot(this.XamlRoot))
{
popup.RequestedTheme = ThemeHelper.RootTheme;
}
}
}
}
}
2 changes: 1 addition & 1 deletion WinUIGallery/standalone.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<!-- The NuGet versions of dependencies to build against. -->
<WindowsAppSdkPackageVersion>1.4.230822000</WindowsAppSdkPackageVersion>
<WindowsAppSdkPackageVersion>1.4.230913002</WindowsAppSdkPackageVersion>
<SamplesTargetFrameworkMoniker>net6.0-windows10.0.19041.0</SamplesTargetFrameworkMoniker>
<MicrosoftNETCoreUniversalWindowsPlatformVersion>6.2.11</MicrosoftNETCoreUniversalWindowsPlatformVersion>
<GraphicsWin2DVersion>1.0.4</GraphicsWin2DVersion>
Expand Down

0 comments on commit 398af50

Please sign in to comment.