diff --git a/WinUIGallery/App.xaml.cs b/WinUIGallery/App.xaml.cs
index d39f131d0..e1c67d2a1 100644
--- a/WinUIGallery/App.xaml.cs
+++ b/WinUIGallery/App.xaml.cs
@@ -116,11 +116,6 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar
startupWindow = WindowHelper.CreateWindow();
startupWindow.ExtendsContentIntoTitleBar = true;
#if DEBUG
- //if (System.Diagnostics.Debugger.IsAttached)
- //{
- // this.DebugSettings.EnableFrameRateCounter = true;
- //}
-
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.BindingFailed += DebugSettings_BindingFailed;
diff --git a/WinUIGallery/Common/ActivityFeedLayout.cs b/WinUIGallery/Common/ActivityFeedLayout.cs
index 545569c18..b1c43e29a 100644
--- a/WinUIGallery/Common/ActivityFeedLayout.cs
+++ b/WinUIGallery/Common/ActivityFeedLayout.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using Windows.Foundation;
using Microsoft.UI.Xaml;
@@ -95,8 +95,7 @@ private static void OnPropertyChanged(DependencyObject obj, DependencyPropertyCh
protected override void InitializeForContextCore(VirtualizingLayoutContext context)
{
base.InitializeForContextCore(context);
-
- if (!(context.LayoutState is ActivityFeedLayoutState state))
+ if (!(context.LayoutState is ActivityFeedLayoutState))
{
// Store any state we might need since (in theory) the layout could be in use by multiple
// elements simultaneously
@@ -169,7 +168,6 @@ protected override Size MeasureOverride(VirtualizingLayoutContext context, Size
for (int columnIndex = 0; columnIndex < 3; columnIndex++)
{
var index = firstItemIndex + columnIndex;
- var rect = boundsForCurrentRow[index % 3];
var container = context.GetOrCreateElementAt(index);
container.Measure(
diff --git a/WinUIGallery/Common/Category.cs b/WinUIGallery/Common/Category.cs
index da3221461..291e3e46b 100644
--- a/WinUIGallery/Common/Category.cs
+++ b/WinUIGallery/Common/Category.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Microsoft.UI.Xaml.Controls;
namespace AppUIBasics.Common
@@ -11,7 +11,6 @@ public class Category : CategoryBase
public string Name { get; set; }
public string Tooltip { get; set; }
public Symbol Glyph { get; set; }
- //public Type TargetType { get; set; }
}
public class Separator : CategoryBase { }
diff --git a/WinUIGallery/Common/ColorSlideTransitionHelper.cs b/WinUIGallery/Common/ColorSlideTransitionHelper.cs
index c8bf477a4..6c337c783 100644
--- a/WinUIGallery/Common/ColorSlideTransitionHelper.cs
+++ b/WinUIGallery/Common/ColorSlideTransitionHelper.cs
@@ -1,4 +1,4 @@
-//*********************************************************
+//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
@@ -25,7 +25,6 @@ public class ColorSlideTransitionHelper
{
#region Member variables
- UIElement hostForVisual;
Compositor _compositor;
ContainerVisual _containerForVisuals;
ScalarKeyFrameAnimation _slideAnimation;
@@ -42,10 +41,6 @@ public class ColorSlideTransitionHelper
///
public ColorSlideTransitionHelper(UIElement hostForVisual)
{
-
-
- this.hostForVisual = hostForVisual;
-
// we have an element in the XAML tree that will host our Visuals
var visual = ElementCompositionPreview.GetElementVisual(hostForVisual);
_compositor = visual.Compositor;
diff --git a/WinUIGallery/Common/MenuItemTemplateSelector.cs b/WinUIGallery/Common/MenuItemTemplateSelector.cs
index 62e30580f..6ae43e0f9 100644
--- a/WinUIGallery/Common/MenuItemTemplateSelector.cs
+++ b/WinUIGallery/Common/MenuItemTemplateSelector.cs
@@ -1,4 +1,4 @@
-using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using System;
@@ -11,8 +11,6 @@ class MenuItemTemplateSelector : DataTemplateSelector
{
public DataTemplate ItemTemplate { get; set; }
- //public string PaneTitle { get; set; }
-
protected override DataTemplate SelectTemplateCore(object item)
{
return item is Separator ? SeparatorTemplate : item is Header ? HeaderTemplate : ItemTemplate;
diff --git a/WinUIGallery/Common/Win32.cs b/WinUIGallery/Common/Win32.cs
index 6fa9424e6..1146c78a1 100644
--- a/WinUIGallery/Common/Win32.cs
+++ b/WinUIGallery/Common/Win32.cs
@@ -19,7 +19,6 @@ internal static class Win32
public const int WM_ACTIVATE = 0x0006;
public const int WA_ACTIVE = 0x01;
- //static int WA_CLICKACTIVE = 0x02;
public const int WA_INACTIVE = 0x00;
public const int WM_SETICON = 0x0080;
diff --git a/WinUIGallery/Common/WrapPanel.cs b/WinUIGallery/Common/WrapPanel.cs
index 5a2c1b26d..914e2dc25 100644
--- a/WinUIGallery/Common/WrapPanel.cs
+++ b/WinUIGallery/Common/WrapPanel.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
@@ -38,7 +38,6 @@ public class WrapPanel : Panel
/// within a . The
/// default value is .
///
- //[TypeConverter(typeof(LengthConverter))]
public double ItemHeight
{
get { return (double)GetValue(ItemHeightProperty); }
@@ -73,7 +72,6 @@ public double ItemHeight
/// contained in a .
/// The default value is .
///
- //[TypeConverter(typeof(LengthConverter))]
public double ItemWidth
{
get { return (double)GetValue(ItemWidthProperty); }
diff --git a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs
index 5577dfed4..1a854cd01 100644
--- a/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs
+++ b/WinUIGallery/ConnectedAnimationPages/CollectionPage.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
@@ -59,8 +59,7 @@ private void collection_ItemClick(object sender, ItemClickEventArgs e)
// Prepare the connected animation.
// Notice that the stored item is passed in, as well as the name of the connected element.
// The animation will actually start on the Detailed info page.
- var animation = collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");
-
+ collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");
}
// Navigate to the DetailedInfoPage.
diff --git a/WinUIGallery/ContentIncludes.props b/WinUIGallery/ContentIncludes.props
index b56b5faa7..467eb0f1e 100644
--- a/WinUIGallery/ContentIncludes.props
+++ b/WinUIGallery/ContentIncludes.props
@@ -372,6 +372,7 @@
+
diff --git a/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs b/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs
index f3c7b0267..5d5810848 100644
--- a/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs
+++ b/WinUIGallery/ControlPages/AppBarSeparatorPage.xaml.cs
@@ -20,16 +20,5 @@ public AppBarSeparatorPage()
{
this.InitializeComponent();
}
- private void CompactButton_Click(object sender, RoutedEventArgs e)
- {
- if ((sender as AppBarToggleButton).IsChecked == true)
- {
- Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Collapsed;
- }
- else
- {
- Control1.DefaultLabelPosition = CommandBarDefaultLabelPosition.Bottom;
- }
- }
}
}
diff --git a/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs b/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs
index fed643b34..195750aa8 100644
--- a/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs
+++ b/WinUIGallery/ControlPages/AppBarToggleButtonPage.xaml.cs
@@ -21,17 +21,6 @@ public AppBarToggleButtonPage()
this.InitializeComponent();
}
- private void CompactButton_Click(object sender, RoutedEventArgs e)
- {
- if (sender is ToggleButton toggle && toggle.IsChecked != null)
- {
- Button1.IsCompact =
- Button2.IsCompact =
- Button3.IsCompact =
- Button4.IsCompact = (bool)toggle.IsChecked;
- }
- }
-
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
if (sender is AppBarToggleButton b)
diff --git a/WinUIGallery/ControlPages/ComboBoxPage.xaml.cs b/WinUIGallery/ControlPages/ComboBoxPage.xaml.cs
index 713827ba9..dc3e84f30 100644
--- a/WinUIGallery/ControlPages/ComboBoxPage.xaml.cs
+++ b/WinUIGallery/ControlPages/ComboBoxPage.xaml.cs
@@ -112,7 +112,7 @@ private void Combo3_TextSubmitted(ComboBox sender, ComboBoxTextSubmittedEventArg
dialog.CloseButtonText = "Close";
dialog.DefaultButton = ContentDialogButton.Close;
dialog.XamlRoot = sender.XamlRoot;
- var task = dialog.ShowAsync();
+ _ = dialog.ShowAsync();
}
// Mark the event as handled so the framework doesn’t update the selected item automatically.
diff --git a/WinUIGallery/ControlPages/CommandBarPage.xaml.cs b/WinUIGallery/ControlPages/CommandBarPage.xaml.cs
index b1bcfc7b7..475b7dfbd 100644
--- a/WinUIGallery/ControlPages/CommandBarPage.xaml.cs
+++ b/WinUIGallery/ControlPages/CommandBarPage.xaml.cs
@@ -58,7 +58,6 @@ private void CloseButton_Click(object sender, RoutedEventArgs e)
private void OnElementClicked(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- var selectedFlyoutItem = sender as AppBarButton;
SelectedOptionText.Text = "You clicked: " + (sender as AppBarButton).Label;
}
diff --git a/WinUIGallery/ControlPages/CreateMultipleWindowsPage.xaml.cs b/WinUIGallery/ControlPages/CreateMultipleWindowsPage.xaml.cs
index 3c51681b8..1e24dec4c 100644
--- a/WinUIGallery/ControlPages/CreateMultipleWindowsPage.xaml.cs
+++ b/WinUIGallery/ControlPages/CreateMultipleWindowsPage.xaml.cs
@@ -1,4 +1,4 @@
-//*********************************************************
+//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
@@ -23,11 +23,6 @@ public CreateMultipleWindowsPage()
this.InitializeComponent();
}
- private void List_GotFocus(object sender, RoutedEventArgs e)
- {
- Control1.StartBringIntoView();
- }
-
private void createNewWindow_Click(object sender, RoutedEventArgs e)
{
var newWindow = WindowHelper.CreateWindow();
diff --git a/WinUIGallery/ControlPages/DesignGuidance/IconsPage.xaml b/WinUIGallery/ControlPages/DesignGuidance/IconsPage.xaml
index 15f78bf2d..9809cdd7c 100644
--- a/WinUIGallery/ControlPages/DesignGuidance/IconsPage.xaml
+++ b/WinUIGallery/ControlPages/DesignGuidance/IconsPage.xaml
@@ -134,7 +134,8 @@
If you don't specify a FontFamily,
or you specify a FontFamily that is not available on the system at runtime,
- the FontIcon falls back to the default font family defined by the SymbolThemeFontFamily resource.
+ the FontIcon falls back to the default font family defined by the SymbolThemeFontFamily resource.
+
An icon with a 16-epx font size is the equivalent of a 16x16-epx icon, to make sizing and positioning more predictable.
For optimal appearance, use these specific sizes: 16, 20, 24, 32, 40, 48, and 64. Deviating from these font sizes could lead to less crisp or blurry outcomes.
diff --git a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml
index 8e8776a6e..5d113f41d 100644
--- a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml
+++ b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml
@@ -293,7 +293,6 @@ private void InitializeData()
Click="OnAnimatedItemClicked"
GotFocus="OnAnimatedItemGotFocus"
HorizontalAlignment="Stretch"
- Loaded="GetButtonSize"
Foreground="{ThemeResource TextFillColorInverseBrush}">
diff --git a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs
index 82bea3597..eca2b7f2f 100644
--- a/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs
+++ b/WinUIGallery/ControlPages/ItemsRepeaterPage.xaml.cs
@@ -25,8 +25,6 @@ public sealed partial class ItemsRepeaterPage : ItemsPageBase
public List staticRecipeData;
private bool IsSortDescending = false;
- private double AnimatedBtnHeight;
- private Thickness AnimatedBtnMargin;
private Button LastSelectedColorButton;
private int PreviouslyFocusedAnimatedScrollRepeaterIndex = -1;
@@ -316,13 +314,6 @@ private void OnElementPrepared(Microsoft.UI.Xaml.Controls.ItemsRepeater sender,
item.StartAnimation("CenterPoint", centerPointExpression);
}
- private void GetButtonSize(object sender, RoutedEventArgs e)
- {
- Button AnimatedBtn = sender as Button;
- AnimatedBtnHeight = AnimatedBtn.ActualHeight;
- AnimatedBtnMargin = AnimatedBtn.Margin;
- }
-
private void SetUIANamesForSelectedEntry(Button selectedItem)
{
if (LastSelectedColorButton != null && LastSelectedColorButton.Content is string content)
@@ -334,27 +325,6 @@ private void SetUIANamesForSelectedEntry(Button selectedItem)
LastSelectedColorButton = selectedItem;
}
- // Find centerpoint of ScrollViewer
- private double CenterPointOfViewportInExtent()
- {
- return Animated_ScrollViewer.VerticalOffset + Animated_ScrollViewer.ViewportHeight / 2;
- }
-
- // Find index of the item that's at the center of the viewport
- private int GetSelectedIndexFromViewport()
- {
- int selectedItemIndex = (int)Math.Floor(CenterPointOfViewportInExtent() / ((double)AnimatedBtnMargin.Top + AnimatedBtnHeight));
- selectedItemIndex %= animatedScrollRepeater.ItemsSourceView.Count;
- return selectedItemIndex;
- }
-
- // Return item that's currently in center of viewport
- private object GetSelectedItemFromViewport()
- {
- var selectedIndex = GetSelectedIndexFromViewport();
- var selectedElement = animatedScrollRepeater.TryGetElement(selectedIndex) as Button;
- return selectedElement;
- }
// ==========================================================================
// VariedImageSize Layout with Filtering/Sorting
diff --git a/WinUIGallery/ControlPages/NavigationViewPage.xaml.cs b/WinUIGallery/ControlPages/NavigationViewPage.xaml.cs
index c8475945d..bd8562663 100644
--- a/WinUIGallery/ControlPages/NavigationViewPage.xaml.cs
+++ b/WinUIGallery/ControlPages/NavigationViewPage.xaml.cs
@@ -198,37 +198,6 @@ private void NavigationView_SelectionChanged9(Microsoft.UI.Xaml.Controls.Navigat
contentFrame9.Navigate(pageType, null, args.RecommendedNavigationTransitionInfo);
}
- private void databindHeader_Checked(object sender, RoutedEventArgs e)
- {
- Categories = new ObservableCollection()
- {
- new Header { Name = "Header1 "},
- new Category { Name = "Category 1", Glyph = Symbol.Home, Tooltip = "This is category 1" },
- new Category { Name = "Category 2", Glyph = Symbol.Keyboard, Tooltip = "This is category 2" },
- new Separator(),
- new Header { Name = "Header2 "},
- new Category {Name = "Category 3", Glyph = Symbol.Library, Tooltip = "This is category 3" },
- new Category {Name = "Category 4", Glyph = Symbol.Mail, Tooltip = "This is category 3" }
- };
- }
-
- private void databindHeader_Checked_Unchecked(object sender, RoutedEventArgs e)
- {
- Categories = new ObservableCollection()
- {
- new Category { Name = "Category 1", Glyph = Symbol.Home, Tooltip = "This is category 1" },
- new Category { Name = "Category 2", Glyph = Symbol.Keyboard, Tooltip = "This is category 2" },
- new Category {Name = "Category 3", Glyph = Symbol.Library, Tooltip = "This is category 3" },
- new Category {Name = "Category 4", Glyph = Symbol.Mail, Tooltip = "This is category 3" }
- };
- }
-
- private void Grid_ManipulationDelta1(object sender, Microsoft.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
- {
- var grid = sender as Grid;
- grid.Width = grid.ActualWidth + e.Delta.Translation.X;
- }
-
private void headerCheck_Click(object sender, RoutedEventArgs e)
{
nvSample.AlwaysShowHeader = (sender as CheckBox).IsChecked == true ? true : false;
diff --git a/WinUIGallery/ControlPages/PullToRefreshPage.xaml.cs b/WinUIGallery/ControlPages/PullToRefreshPage.xaml.cs
index d3ccae256..833b52523 100644
--- a/WinUIGallery/ControlPages/PullToRefreshPage.xaml.cs
+++ b/WinUIGallery/ControlPages/PullToRefreshPage.xaml.cs
@@ -118,7 +118,6 @@ public PullToRefreshPage()
private void PullToRefreshPage_Loaded(object sender, RoutedEventArgs e)
{
visualizerContentVisual = ElementCompositionPreview.GetElementVisual(rv2.Content);
-
this.Loaded -= PullToRefreshPage_Loaded;
}
@@ -200,7 +199,7 @@ private void rc2_RefreshRequested(RefreshContainer sender, RefreshRequestedEvent
private void rv2_RefreshStateChanged(RefreshVisualizer sender, RefreshStateChangedEventArgs args)
{
- //visualizerContentVisual.StopAnimation("RotationAngle");
+ visualizerContentVisual.StopAnimation("RotationAngle");
}
}
}
diff --git a/WinUIGallery/ControlPages/RichEditBoxPage.xaml.cs b/WinUIGallery/ControlPages/RichEditBoxPage.xaml.cs
index 49589c791..6a2c40902 100644
--- a/WinUIGallery/ControlPages/RichEditBoxPage.xaml.cs
+++ b/WinUIGallery/ControlPages/RichEditBoxPage.xaml.cs
@@ -188,7 +188,7 @@ private void FindBoxRemoveHighlights()
private void Editor_GotFocus(object sender, RoutedEventArgs e)
{
- editor.Document.GetText(TextGetOptions.UseCrlf, out string currentRawText);
+ editor.Document.GetText(TextGetOptions.UseCrlf, out _);
// reset colors to correct defaults for Focused state
ITextRange documentRange = editor.Document.GetRange(0, TextConstants.MaxUnitCount);
@@ -200,18 +200,6 @@ private void Editor_GotFocus(object sender, RoutedEventArgs e)
}
}
- private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
- {
- if (e.NewSize.Width <= 768)
- {
- editor.Width = e.NewSize.Width - 20;
- }
- else
- {
- editor.Width = e.NewSize.Width - 100;
- }
- }
-
private void REBCustom_Loaded(object sender, RoutedEventArgs e)
{
// Prior to UniversalApiContract 7, RichEditBox did not have a default ContextFlyout set.
@@ -243,4 +231,4 @@ private void Editor_TextChanged(object sender, RoutedEventArgs e)
}
}
}
-}
\ No newline at end of file
+}
diff --git a/WinUIGallery/ControlPages/ScrollViewerPage.xaml.cs b/WinUIGallery/ControlPages/ScrollViewerPage.xaml.cs
index 3fd868873..b32f9239f 100644
--- a/WinUIGallery/ControlPages/ScrollViewerPage.xaml.cs
+++ b/WinUIGallery/ControlPages/ScrollViewerPage.xaml.cs
@@ -10,6 +10,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Input;
namespace AppUIBasics.ControlPages
{
@@ -26,13 +27,13 @@ private void ZoomModeComboBox_SelectionChanged(object sender, SelectionChangedEv
if (ScrollViewerControl != null && ZoomSlider != null)
{
if (sender is ComboBox cb)
- {
+ {
ScrollViewerControl.ZoomMode = (ZoomMode)cb.SelectedIndex;
- ZoomSlider.IsEnabled = cb.SelectedIndex == 1;
+ ZoomSlider.IsEnabled = cb.SelectedIndex == 1;
- if (!ZoomSlider.IsEnabled)
- {
- ScrollViewerControl.ZoomToFactor(2.0f);
+ if (!ZoomSlider.IsEnabled)
+ {
+ ScrollViewerControl.ZoomToFactor(2.0f);
}
}
}
@@ -62,7 +63,7 @@ private void hsbvCombo_SelectionChanged(object sender, SelectionChangedEventArgs
if (ScrollViewerControl != null)
{
if (sender is ComboBox cb)
- {
+ {
ScrollViewerControl.HorizontalScrollBarVisibility = (ScrollBarVisibility)cb.SelectedIndex;
}
}
@@ -73,7 +74,7 @@ private void vsmCombo_SelectionChanged(object sender, SelectionChangedEventArgs
if (ScrollViewerControl != null)
{
if (sender is ComboBox cb)
- {
+ {
ScrollViewerControl.VerticalScrollMode = (ScrollMode)cb.SelectedIndex;
}
}
@@ -84,17 +85,22 @@ private void vsbvCombo_SelectionChanged(object sender, SelectionChangedEventArgs
if (ScrollViewerControl != null)
{
if (sender is ComboBox cb)
- {
+ {
ScrollViewerControl.VerticalScrollBarVisibility = (ScrollBarVisibility)cb.SelectedIndex;
}
}
}
+ private void ScrollViewerControl_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
+ {
+ ZoomSlider.Value = ScrollViewerControl.ZoomFactor;
+ }
+
private void ScrollViewerControl_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
- if (!e.IsIntermediate)
- {
- ZoomSlider.Value = ScrollViewerControl.ZoomFactor;
+ if (!e.IsIntermediate)
+ {
+ ZoomSlider.Value = ScrollViewerControl.ZoomFactor;
}
}
}
diff --git a/WinUIGallery/ControlPages/SplitViewPage.xaml.cs b/WinUIGallery/ControlPages/SplitViewPage.xaml.cs
index a054a6c41..31b84dbcf 100644
--- a/WinUIGallery/ControlPages/SplitViewPage.xaml.cs
+++ b/WinUIGallery/ControlPages/SplitViewPage.xaml.cs
@@ -39,28 +39,6 @@ public SplitViewPage()
this.InitializeComponent();
}
- private void togglePaneButton_Click(object sender, RoutedEventArgs e)
- {
- Window window = WindowHelper.GetWindowForElement(this);
- if (window.Bounds.Width >= 640)
- {
- if (splitView.IsPaneOpen)
- {
- splitView.DisplayMode = SplitViewDisplayMode.CompactOverlay;
- splitView.IsPaneOpen = false;
- }
- else
- {
- splitView.IsPaneOpen = true;
- splitView.DisplayMode = SplitViewDisplayMode.Inline;
- }
- }
- else
- {
- splitView.IsPaneOpen = !splitView.IsPaneOpen;
- }
- }
-
private void NavLinksList_ItemClick(object sender, ItemClickEventArgs e)
{
content.Text = (e.ClickedItem as NavLink).Label + " Page";
diff --git a/WinUIGallery/ControlPages/StandardUICommandPage.xaml b/WinUIGallery/ControlPages/StandardUICommandPage.xaml
index cb9b7e8e6..c1a2f7563 100644
--- a/WinUIGallery/ControlPages/StandardUICommandPage.xaml
+++ b/WinUIGallery/ControlPages/StandardUICommandPage.xaml
@@ -54,7 +54,7 @@
-
+
diff --git a/WinUIGallery/ControlPages/StandardUICommandPage.xaml.cs b/WinUIGallery/ControlPages/StandardUICommandPage.xaml.cs
index ca8ae0b5a..31f82a490 100644
--- a/WinUIGallery/ControlPages/StandardUICommandPage.xaml.cs
+++ b/WinUIGallery/ControlPages/StandardUICommandPage.xaml.cs
@@ -49,14 +49,6 @@ private void ListView_Loaded(object sender, RoutedEventArgs e)
listView.ItemsSource = collection;
}
- private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (ListViewRight.SelectedIndex != -1)
- {
- var item = collection[ListViewRight.SelectedIndex];
- }
- }
-
private void ListViewSwipeContainer_PointerEntered(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType == Microsoft.UI.Input.PointerDeviceType.Mouse || e.Pointer.PointerDeviceType == Microsoft.UI.Input.PointerDeviceType.Pen)
diff --git a/WinUIGallery/ControlPages/TitleBarPage.xaml b/WinUIGallery/ControlPages/TitleBarPage.xaml
index 4823654ba..cbb726853 100644
--- a/WinUIGallery/ControlPages/TitleBarPage.xaml
+++ b/WinUIGallery/ControlPages/TitleBarPage.xaml
@@ -26,13 +26,35 @@
+
+
+
+
+ WinUI provides a default titlebar in such cases where the user doesn't explicitly provide a uielement, for setting the titlebar. The system titlebar (Windows-provided titlebar) disappears and client area content is extended to non client area.
+ In this default case, entire non client region (titlebar region) get system titlebar behaviors like drag regions, system menu on context click etc.
+
+ This is the recommended way of using TitleBar apis and covers most common scenarios.
+
+ It can be applied by just calling ExtendsContentIntoTitleBar api. This internally calls SetTitleBar api with null argument and provides the default case.
+
+ Use the button below to toggle between system titlebar and default custom titlebar.
+
+
+
+
+
+
+
- User can set a top-level UIElement (defined as appTitleBar here) as titlebar for the window. The system titlebar disappears and the chosen uielement starts acting like the titlebar.
+ For finer controls, a user can set a top-level UIElement (defined as appTitleBar here) as titlebar for the window. The system titlebar disappears and the chosen uielement starts acting like the titlebar (gets all system titlebar behavior).
The Background and Foreground Color dropdowns set the foreground and background of titlebar and caption buttons respectively.
+
+ Use the button below to toggle between system titlebar and custom WinUI titlebar.
@@ -64,7 +86,8 @@
-
+
+
@@ -111,23 +134,33 @@
-
+
- WinUI provides a fallback titlebar in case where user doesn't want to provide a uielement for setting the titlebar.
- A small horizontal section next to min/max/close caption buttons is chosen as the fallback titlebar.
-
- It can be applied by just calling ExtendsContentIntoTitleBar api only and not calling SetTitleBar afterwards. It can also be manually triggered by calling SetTitleBar api with null arument.
+ WinUI custom titlebar now hosting interactive clickable controls within non client region of the window, when using custom titlebar.
- Use the Color dropdown controls in the section above to change color of the fallback titlebar.
+ This is achieved by using lower level
+
+ Microsoft.UI.AppWindowTitlebar
+
+ and
+ Microsoft.UI.NonClientInputPointerSource apis
+
+
+ WinUI allows mix and match of higher level WinUI custom titlebar apis with lower level AppWindow and NonClientInputPointerSource apis for most cases.
+ One exception is one should not use Window.SetTitlebar api along with any lower level api which also sets drag regions as it can result in unexpected behavior.
+ If needed, set Window.SetTitlebar to null (default case) and proceed to use lower level apis for drag functionality.
+
+ Use the button below to toggle between system titlebar and default custom titlebar.
-
+
+
diff --git a/WinUIGallery/ControlPages/TitleBarPage.xaml.cs b/WinUIGallery/ControlPages/TitleBarPage.xaml.cs
index 6bb3fa5d8..94ad67f21 100644
--- a/WinUIGallery/ControlPages/TitleBarPage.xaml.cs
+++ b/WinUIGallery/ControlPages/TitleBarPage.xaml.cs
@@ -15,6 +15,12 @@
using WinUIGallery.DesktopWap.Helper;
using Microsoft.UI.Xaml.Shapes;
using System.Threading.Tasks;
+using Microsoft.UI.Windowing;
+using Microsoft.UI.Xaml.Navigation;
+using Microsoft.UI.Input;
+using System.IO;
+using Windows.Foundation;
+using System;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -29,7 +35,8 @@ namespace AppUIBasics.ControlPages
public sealed partial class TitleBarPage : Page
{
private Windows.UI.Color currentBgColor = Colors.Transparent;
- private Windows.UI.Color currentFgColor = Colors.Transparent;
+ private Windows.UI.Color currentFgColor = ThemeHelper.ActualTheme == ElementTheme.Dark ? Colors.White : Colors.Black;
+ private bool sizeChangedEventHandlerAdded = false;
public TitleBarPage()
{
@@ -41,8 +48,14 @@ public TitleBarPage()
};
}
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ ResetTitlebarSettings();
+ }
+
+
- private void SetTitleBar(UIElement titlebar)
+ private void SetTitleBar(UIElement titlebar, bool forceCustomTitlebar = false)
{
var window = WindowHelper.GetWindowForElement(this as UIElement);
var titleBarElement = UIHelper.FindElementByName(this, "AppTitleBar");
@@ -65,19 +78,44 @@ private void SetTitleBar(UIElement titlebar)
UpdateTitleBarColor();
}
+ private void ResetTitlebarSettings()
+ {
+ var window = WindowHelper.GetWindowForElement(this as UIElement);
+ UIElement titleBarElement = UIHelper.FindElementByName(this as UIElement, "AppTitleBar");
+ SetTitleBar(titleBarElement, forceCustomTitlebar: true);
+ ClearClickThruRegions();
+ var txtBoxNonClientArea = UIHelper.FindElementByName(this as UIElement, "AppTitleBarTextBox") as FrameworkElement;
+ txtBoxNonClientArea.Visibility = Visibility.Collapsed;
+ addInteractiveElements.Content = "Add interactive control to titlebar";
+ }
+
+ private void SetClickThruRegions(Windows.Graphics.RectInt32[] rects)
+ {
+ var window = WindowHelper.GetWindowForElement(this as UIElement);
+ var nonClientInputSrc = InputNonClientPointerSource.GetForWindowId(window.AppWindow.Id);
+ nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, rects);
+ }
+
+ private void ClearClickThruRegions()
+ {
+ var window = WindowHelper.GetWindowForElement(this as UIElement);
+ var noninputsrc = InputNonClientPointerSource.GetForWindowId(window.AppWindow.Id);
+ noninputsrc.ClearRegionRects(NonClientRegionKind.Passthrough);
+ }
+
public void UpdateButtonText()
{
var window = WindowHelper.GetWindowForElement(this as UIElement);
if (window.ExtendsContentIntoTitleBar)
{
- customTitleBar.Content = "Reset to system TitleBar";
- defaultTitleBar.Content = "Reset to system TitleBar";
+ customTitleBar.Content = "Reset to System TitleBar";
+ defaultTitleBar.Content = "Reset to System TitleBar";
}
else
{
customTitleBar.Content = "Set Custom TitleBar";
- defaultTitleBar.Content = "Set Fallback Custom TitleBar";
+ defaultTitleBar.Content = "Set Default Custom TitleBar";
}
}
@@ -142,7 +180,6 @@ private void customTitleBar_Click(object sender, RoutedEventArgs e)
{
UIElement titleBarElement = UIHelper.FindElementByName(sender as UIElement, "AppTitleBar");
SetTitleBar(titleBarElement);
-
// announce visual change to automation
UIHelper.AnnounceActionForAccessibility(sender as UIElement, "TitleBar size and width changed", "TitleBarChangedNotificationActivityId");
}
@@ -153,5 +190,48 @@ private void defaultTitleBar_Click(object sender, RoutedEventArgs e)
// announce visual change to automation
UIHelper.AnnounceActionForAccessibility(sender as UIElement, "TitleBar size and width changed", "TitleBarChangedNotificationActivityId");
}
+
+ private void AddInteractiveElements_Click(object sender, RoutedEventArgs e)
+ {
+ var txtBoxNonClientArea = UIHelper.FindElementByName(sender as UIElement, "AppTitleBarTextBox") as FrameworkElement;
+
+ if (txtBoxNonClientArea.Visibility == Visibility.Visible)
+ {
+ ResetTitlebarSettings();
+ }
+ else
+ {
+ addInteractiveElements.Content = "Remove interactive control from titlebar";
+ txtBoxNonClientArea.Visibility = Visibility.Visible;
+ if (!sizeChangedEventHandlerAdded)
+ {
+ sizeChangedEventHandlerAdded = true;
+ // run this code when textbox has been made visible and its actual width and height has been calculated
+ txtBoxNonClientArea.SizeChanged += (object sender, SizeChangedEventArgs e) =>
+ {
+ if (txtBoxNonClientArea.Visibility != Visibility.Collapsed)
+ {
+ GeneralTransform transformTxtBox = txtBoxNonClientArea.TransformToVisual(null);
+ Rect bounds = transformTxtBox.TransformBounds(new Rect(0, 0, txtBoxNonClientArea.ActualWidth, txtBoxNonClientArea.ActualHeight));
+
+ var scale = WindowHelper.GetRasterizationScaleForElement(this);
+
+ var transparentRect = new Windows.Graphics.RectInt32(
+ _X: (int)Math.Round(bounds.X * scale),
+ _Y: (int)Math.Round(bounds.Y * scale),
+ _Width: (int)Math.Round(bounds.Width * scale),
+ _Height: (int)Math.Round(bounds.Height * scale)
+ );
+ var rectArr = new Windows.Graphics.RectInt32[] { transparentRect };
+ SetClickThruRegions(rectArr);
+ }
+ };
+ }
+ txtBoxNonClientArea.Width += 1; //to trigger size changed event
+ }
+ // announce visual change to automation
+ UIHelper.AnnounceActionForAccessibility(sender as UIElement, "TitleBar size and width changed", "TitleBarChangedNotificationActivityId");
+ }
+
}
}
diff --git a/WinUIGallery/ControlPagesSampleCode/ItemsRepeater/ItemsRepeaterSample3_xaml.txt b/WinUIGallery/ControlPagesSampleCode/ItemsRepeater/ItemsRepeaterSample3_xaml.txt
index a77f0f637..939916af0 100644
--- a/WinUIGallery/ControlPagesSampleCode/ItemsRepeater/ItemsRepeaterSample3_xaml.txt
+++ b/WinUIGallery/ControlPagesSampleCode/ItemsRepeater/ItemsRepeaterSample3_xaml.txt
@@ -22,7 +22,6 @@ color-changing rectangle besides it. -->
Click="Animated_GotItem"
GotFocus="Animated_GotItem"
HorizontalAlignment="Stretch"
- Loaded="GetButtonSize"
Foreground="{ThemeResource ButtonForeground}"/>
diff --git a/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt b/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt
index dcd9af9db..a3b36842d 100644
--- a/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt
+++ b/WinUIGallery/ControlPagesSampleCode/Motion/ConnectedAnimation/ConnectedAnimationSample1_cs.txt
@@ -54,8 +54,7 @@ public sealed partial class CollectionPage : Page
// Prepare the connected animation.
// Notice that the stored item is passed in, as well as the name of the connected element.
// The animation will actually start on the Detailed info page.
- var animation = collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");
-
+ collection.PrepareConnectedAnimation("ForwardConnectedAnimation", _storeditem, "connectedElement");
}
// Navigate to the DetailedInfoPage.
diff --git a/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt b/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt
index 9ee56c174..3e43ca381 100644
--- a/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt
+++ b/WinUIGallery/ControlPagesSampleCode/Text/RichEditBox/RichEditBoxSample3_cs.txt
@@ -111,7 +111,7 @@ private void FindBoxRemoveHighlights()
private void Editor_GotFocus(object sender, RoutedEventArgs e)
{
- editor.Document.GetText(TextGetOptions.UseCrlf, out string currentRawText);
+ editor.Document.GetText(TextGetOptions.UseCrlf, out _);
// reset colors to correct defaults for Focused state
ITextRange documentRange = editor.Document.GetRange(0, TextConstants.MaxUnitCount);
diff --git a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt
index 752e3b23f..d6bcc6eaf 100644
--- a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt
+++ b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample2.txt
@@ -1,4 +1,4 @@
-// no UIElement is set for titlebar, fallback titlebar is created
+// no UIElement is set for titlebar, default titlebar is created which extends to entire non client area
Window window = App.MainWindow;
window.ExtendsContentIntoTitleBar = true;
-window.SetTitleBar(null); // this line is optional as by it is null by default
+// window.SetTitleBar(null); // optional line as not setting any UIElement as titlebar is same as setting null as titlebar
diff --git a/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt
new file mode 100644
index 000000000..f3afd4b40
--- /dev/null
+++ b/WinUIGallery/ControlPagesSampleCode/Window/TitleBar/TitleBarSample3.txt
@@ -0,0 +1,22 @@
+Window window = App.MainWindow;
+window.ExtendsContentIntoTitleBar = true;
+window.SetTitleBar(AppTitleBar);
+var nonClientInputSrc = InputNonClientPointerSource.GetForWindowId(window.AppWindow.Id);
+
+// textbox on titlebar area
+var txtBoxNonClientArea = UIHelper.FindElementByName(sender as UIElement, "AppTitleBarTextBox") as FrameworkElement;
+GeneralTransform transformTxtBox = txtBoxNonClientArea.TransformToVisual(null);
+Rect bounds = transformTxtBox.TransformBounds(new Rect(0, 0, txtBoxNonClientArea.ActualWidth, txtBoxNonClientArea.ActualHeight));
+
+// Windows.Graphics.RectInt32[] rects defines the area which allows click throughs in custom titlebar
+// it is non dpi-aware client coordinates. Hence, we convert dpi aware coordinates to non-dpi coordinates
+var scale = WindowHelper.GetRasterizationScaleForElement(this);
+var transparentRect = new Windows.Graphics.RectInt32(
+ _X: (int)Math.Round(bounds.X * scale),
+ _Y: (int)Math.Round(bounds.Y * scale),
+ _Width: (int)Math.Round(bounds.Width * scale),
+ _Height: (int)Math.Round(bounds.Height * scale)
+);
+var rects = new Windows.Graphics.RectInt32[] { transparentRect };
+
+nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, rects); // areas defined will be click through and can host button and textboxes
diff --git a/WinUIGallery/Controls/ControlExample.xaml b/WinUIGallery/Controls/ControlExample.xaml
index c62b28310..6b2e8c008 100644
--- a/WinUIGallery/Controls/ControlExample.xaml
+++ b/WinUIGallery/Controls/ControlExample.xaml
@@ -80,7 +80,7 @@
IsTextSelectionEnabled="True"
Visibility="Collapsed">
- This sample requires a later version of Windows to be fully functional. Learn more about version adaptive apps:https://learn.microsoft.com/windows/uwp/debug-test-perf/version-adaptive-apps
+ This sample requires a later version of Windows to be fully functional.
diff --git a/WinUIGallery/Controls/HeaderTile.xaml.cs b/WinUIGallery/Controls/HeaderTile.xaml.cs
index 3a5c643bf..2f58e80f4 100644
--- a/WinUIGallery/Controls/HeaderTile.xaml.cs
+++ b/WinUIGallery/Controls/HeaderTile.xaml.cs
@@ -22,9 +22,6 @@ namespace AppUIBasics.Controls
{
public sealed partial class HeaderTile : UserControl
{
- Compositor _compositor = Microsoft.UI.Xaml.Media.CompositionTarget.GetCompositorForCurrentThread();
- private SpringVector3NaturalMotionAnimation _springAnimation;
-
public string Title
{
get { return (string)GetValue(TitleProperty); }
@@ -66,33 +63,5 @@ public HeaderTile()
{
this.InitializeComponent();
}
-
- private void Element_PointerEntered(object sender, PointerRoutedEventArgs e)
- {
- CreateOrUpdateSpringAnimation(1.1f);
- (sender as UIElement).CenterPoint = new Vector3(70, 40, 1f);
- (sender as UIElement).StartAnimation(_springAnimation);
- }
-
- private void Element_PointerExited(object sender, PointerRoutedEventArgs e)
- {
- CreateOrUpdateSpringAnimation(1.0f);
- (sender as UIElement).CenterPoint = new Vector3(70, 40, 1f);
- (sender as UIElement).StartAnimation(_springAnimation);
- }
-
- private void CreateOrUpdateSpringAnimation(float finalValue)
- {
- if (_springAnimation == null)
- {
- if (_compositor != null)
- {
- _springAnimation = _compositor.CreateSpringVector3Animation();
- _springAnimation.Target = "Scale";
- }
- }
-
- _springAnimation.FinalValue = new Vector3(finalValue);
- }
}
}
diff --git a/WinUIGallery/DataModel/ControlInfoData.json b/WinUIGallery/DataModel/ControlInfoData.json
index 93afa0e78..7e0c02a62 100644
--- a/WinUIGallery/DataModel/ControlInfoData.json
+++ b/WinUIGallery/DataModel/ControlInfoData.json
@@ -534,6 +534,7 @@
"ApiNamespace": "Microsoft.UI.Xaml.Controls",
"Subtitle": "A control that presents a collection of items using various layouts.",
"ImagePath": "ms-appx:///Assets/ControlImages/ItemsView.png",
+ "ImageIconPath": "ms-appx:///Assets/ControlIcons/ListViewIcon.png",
"Description": "The ItemsView lets you show a collection of items using scrollable & swappable layouts.",
"Content": "
ItemsView can contain a collection of items of any type. To populate the view, set the ItemsSource property to a data source.
Set a Layout to define how the items are laid out.
Set an ItemTemplate to define the look of individual items.
Look at the ItemsViewPage.xaml file in Visual Studio to see the full code for this page.
",
"IsNew": true,
@@ -1428,6 +1429,7 @@
"ApiNamespace": "Microsoft.UI.Xaml.Controls",
"Subtitle": "A control that extends a regular vertical scrollbar's functionality for an easy navigation through large collections.",
"ImagePath": "ms-appx:///Assets/ControlImages/Placeholder.png",
+ "ImageIconPath": "ms-appx:///Assets/ControlIcons/ScrollViewerIcon.png",
"Description": "The AnnotatedScrollBar lets you navigate through a large collection of items via a clickable rail with labels which act as markers.",
"Content": "
AnnotatedScrollBar can be connected to a scrollable container, like a ScrollView, via its ScrollController property.
Populate the Labels property with special values that act as markers.
Set the LabelTemplate and DetailLabelTemplate data templates to define the labels' and more granular tooltips' looks.
Look at the AnnotatedScrollBarPage.xaml file in Visual Studio to see the full code for this page.
",
"IsNew": true,
@@ -1473,7 +1475,7 @@
"ApiNamespace": "Microsoft.UI.Xaml.Controls",
"Subtitle": "A container control that lets the user pan and zoom its content.",
"ImagePath": "ms-appx:///Assets/ControlImages/ScrollView.png",
- "ImageIconPath": "ms-appx:///Assets/ControlIcons/ScrollViewIcon.png",
+ "ImageIconPath": "ms-appx:///Assets/ControlIcons/ScrollViewerIcon.png",
"Description": "A ScrollView lets a user scroll, pan, and zoom to see content that's larger than the viewable area. The ItemsView has a ScrollView built into its control template to provide automatic scrolling.",
"Content": "
Look at the ScrollViewPage.xaml file in Visual Studio to see the full code for this page.
",
"IsNew": true,
@@ -2727,15 +2729,11 @@
},
{
"Title": "Composition Animation - API",
- "Uri": "https://learn.microsoft.com/windows/uwp/composition/composition-animation"
+ "Uri": "https://learn.microsoft.com/windows/apps/windows-app-sdk/composition"
},
{
"Title": "Guidelines - Xaml Property Animations",
"Uri": "https://learn.microsoft.com/windows/apps/design/motion/xaml-property-animations"
- },
- {
- "Title": "Using the Visual Layer with XAML",
- "Uri": "https://learn.microsoft.com/windows/uwp/composition/using-the-visual-layer-with-xaml"
}
],
"RelatedControls": [
@@ -2830,7 +2828,7 @@
"Subtitle": "An example showing a custom UIElement used as the titlebar for the app's window.",
"ImagePath": "ms-appx:///Assets/ControlImages/TitleBar.png",
"ImageIconPath": "ms-appx:///Assets/ControlIcons/DefaultIcon.png",
- "Description": "This sample shows how to use a custom UIElement as titlebar for app's window.",
+ "Description": "This sample shows how to use a custom titlebar for the app's window. There are 2 ways of doing it: using default titlebar and setting an UIElement as a custom titlebar.",
"Content": "
Look at the TitleBarPage.xaml file in Visual Studio to see the full code for this page.
",
"IsUpdated": true,
"Docs": [
diff --git a/WinUIGallery/Directory.Build.targets b/WinUIGallery/Directory.Build.targets
index 02e07802b..f2130e3c0 100644
--- a/WinUIGallery/Directory.Build.targets
+++ b/WinUIGallery/Directory.Build.targets
@@ -5,5 +5,7 @@
WinUIGallery.Desktop
-
+
+
+
\ No newline at end of file
diff --git a/WinUIGallery/Helper/NavigationHelper.cs b/WinUIGallery/Helper/NavigationHelper.cs
index a35735ae7..d4565c98e 100644
--- a/WinUIGallery/Helper/NavigationHelper.cs
+++ b/WinUIGallery/Helper/NavigationHelper.cs
@@ -215,17 +215,6 @@ private bool TryGoBack()
return navigated;
}
- private bool TryGoForward()
- {
- bool navigated = false;
- if (this.Frame.CanGoForward)
- {
- this.Frame.GoForward();
- navigated = true;
- }
- return navigated;
- }
-
private void UpdateBackButton()
{
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6))
@@ -234,75 +223,6 @@ private void UpdateBackButton()
this.CurrentNavView.IsBackEnabled = this.Frame.CanGoBack ? true : false;
}
}
-
- // ///
- // /// Invoked on every keystroke, including system keys such as Alt key combinations.
- // /// Used to detect keyboard navigation between pages even when the page itself
- // /// doesn't have focus.
- // ///
- // /// Instance that triggered the event.
- // /// Event data describing the conditions that led to the event.
- // private void CoreDispatcher_AcceleratorKeyActivated(DispatcherQueue sender,
- // AcceleratorKeyEventArgs e)
- // {
- // var virtualKey = e.VirtualKey;
-
- // // Only investigate further when Left, Right, or the dedicated Previous or Next keys
- // // are pressed
- // if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
- // e.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
- // (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right ||
- // (int)virtualKey == 166 || (int)virtualKey == 167))
- // {
- // var downState = CoreVirtualKeyStates.Down;
- // bool menuKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Menu) & downState) == downState;
- // bool controlKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control) & downState) == downState;
- // bool shiftKey = (Microsoft.UI.Input.InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Shift) & downState) == downState;
- // bool noModifiers = !menuKey && !controlKey && !shiftKey;
- // bool onlyAlt = menuKey && !controlKey && !shiftKey;
-
- // if (((int)virtualKey == 166 && noModifiers) ||
- // (virtualKey == VirtualKey.Left && onlyAlt))
- // {
- // // When the previous key or Alt+Left are pressed navigate back
- // e.Handled = TryGoBack();
- // }
- // else if (((int)virtualKey == 167 && noModifiers) ||
- // (virtualKey == VirtualKey.Right && onlyAlt))
- // {
- // // When the next key or Alt+Right are pressed navigate forward
- // e.Handled = TryGoForward();
- // }
- // }
- // }
-
- // ///
- // /// Invoked on every mouse click, touch screen tap, or equivalent interaction.
- // /// Used to detect browser-style next and previous mouse button clicks
- // /// to navigate between pages.
- // ///
- // /// Instance that triggered the event.
- // /// Event data describing the conditions that led to the event.
- // private void CoreWindow_PointerPressed(CoreWindow sender,
- // PointerEventArgs e)
- // {
- // var properties = e.CurrentPoint.Properties;
-
- // // Ignore button chords with the left, right, and middle buttons
- // if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed ||
- // properties.IsMiddleButtonPressed)
- // return;
-
- // // If back or forward are pressed (but not both) navigate appropriately
- // bool backPressed = properties.IsXButton1Pressed;
- // bool forwardPressed = properties.IsXButton2Pressed;
- // if (backPressed ^ forwardPressed)
- // {
- // e.Handled = true;
- // if (backPressed) this.TryGoBack();
- // if (forwardPressed) this.TryGoForward();
- // }
- // }
}
///
diff --git a/WinUIGallery/Helper/ThemeHelper.cs b/WinUIGallery/Helper/ThemeHelper.cs
index cb2f6e5ea..9a6df40cf 100644
--- a/WinUIGallery/Helper/ThemeHelper.cs
+++ b/WinUIGallery/Helper/ThemeHelper.cs
@@ -13,7 +13,6 @@ public static class ThemeHelper
{
private const string SelectedAppThemeKey = "SelectedAppTheme";
- private static Window CurrentApplicationWindow;
///
/// Gets the current actual theme of the app based on the requested theme of the
/// root element, or if that value is Default, the requested theme of the Application.
@@ -75,8 +74,6 @@ public static void Initialize()
{
if (NativeHelper.IsAppPackaged)
{
- // Save reference as this might be null when the user is in another app
- CurrentApplicationWindow = App.StartupWindow;
string savedTheme = ApplicationData.Current.LocalSettings.Values[SelectedAppThemeKey]?.ToString();
if (savedTheme != null)
diff --git a/WinUIGallery/Helper/TitleBarHelper.cs b/WinUIGallery/Helper/TitleBarHelper.cs
index 68f144755..8da356aac 100644
--- a/WinUIGallery/Helper/TitleBarHelper.cs
+++ b/WinUIGallery/Helper/TitleBarHelper.cs
@@ -19,30 +19,13 @@
namespace WinUIGallery.DesktopWap.Helper
{
+
internal class TitleBarHelper
{
-
- private static void triggerTitleBarRepaint(Window window)
- {
- // to trigger repaint tracking task id 38044406
- var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
- var activeWindow = AppUIBasics.Win32.GetActiveWindow();
- if (hwnd == activeWindow)
- {
- AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_INACTIVE, IntPtr.Zero);
- AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_ACTIVE, IntPtr.Zero);
- }
- else
- {
- AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_ACTIVE, IntPtr.Zero);
- AppUIBasics.Win32.SendMessage(hwnd, AppUIBasics.Win32.WM_ACTIVATE, AppUIBasics.Win32.WA_INACTIVE, IntPtr.Zero);
- }
-
- }
-
+ // workaround as Appwindow titlebar doesn't update caption button colors correctly when changed while app is running
+ // https://task.ms/44172495
public static Windows.UI.Color ApplySystemThemeToCaptionButtons(Window window)
{
- var res = Application.Current.Resources;
var frame = (Application.Current as AppUIBasics.App).GetRootFrame() as FrameworkElement;
Windows.UI.Color color;
if (frame.ActualTheme == ElementTheme.Dark)
@@ -61,7 +44,7 @@ public static void SetCaptionButtonColors(Window window, Windows.UI.Color color)
{
var res = Application.Current.Resources;
res["WindowCaptionForeground"] = color;
- triggerTitleBarRepaint(window);
+ window.AppWindow.TitleBar.ButtonForegroundColor = color;
}
public static void SetCaptionButtonBackgroundColors(Window window, Windows.UI.Color? color)
diff --git a/WinUIGallery/Helper/WindowHelper.cs b/WinUIGallery/Helper/WindowHelper.cs
index 5398cb12e..5bb134e30 100644
--- a/WinUIGallery/Helper/WindowHelper.cs
+++ b/WinUIGallery/Helper/WindowHelper.cs
@@ -66,6 +66,21 @@ static public Window GetWindowForElement(UIElement element)
}
return null;
}
+ // get dpi for an element
+ static public double GetRasterizationScaleForElement(UIElement element)
+ {
+ if (element.XamlRoot != null)
+ {
+ foreach (Window window in _activeWindows)
+ {
+ if (element.XamlRoot == window.Content.XamlRoot)
+ {
+ return element.XamlRoot.RasterizationScale;
+ }
+ }
+ }
+ return 0.0;
+ }
static public List ActiveWindows { get { return _activeWindows; }}
diff --git a/WinUIGallery/IdleSynchronizer.cs b/WinUIGallery/IdleSynchronizer.cs
index 3c02b1807..dc1092973 100644
--- a/WinUIGallery/IdleSynchronizer.cs
+++ b/WinUIGallery/IdleSynchronizer.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using AppUIBasics.Helper;
@@ -25,8 +25,6 @@ class IdleSynchronizer
const string s_rootVisualResetHandleName = "RootVisualReset";
const string s_imageDecodingIdleHandleName = "ImageDecodingIdle";
const string s_fontDownloadsIdleHandleName = "FontDownloadsIdle";
- const string s_hasBuildTreeWorksHandleName = "HasBuildTreeWorks";
- const string s_buildTreeServiceDrainedHandleName = "BuildTreeServiceDrained";
private DispatcherQueue m_dispatcherQueue = null;
@@ -37,8 +35,6 @@ class IdleSynchronizer
private Handle m_rootVisualResetHandle;
private Handle m_imageDecodingIdleHandle;
private Handle m_fontDownloadsIdleHandle;
- private Handle m_hasBuildTreeWorksHandle;
- private Handle m_buildTreeServiceDrainedHandle;
private bool m_waitForAnimationsIsDisabled = false;
private bool m_isRS2OrHigherInitialized = false;
@@ -71,11 +67,6 @@ private Handle OpenNamedEvent(uint processId, uint threadId, string eventNamePre
return handle;
}
- private Handle OpenNamedEvent(uint threadId, string eventNamePrefix)
- {
- return OpenNamedEvent(NativeMethods.GetCurrentProcessId(), threadId, eventNamePrefix);
- }
-
private Handle OpenNamedEvent(DispatcherQueue dispatcherQueue, string eventNamePrefix)
{
return OpenNamedEvent(NativeMethods.GetCurrentProcessId(), GetUIThreadId(dispatcherQueue), eventNamePrefix);
@@ -134,8 +125,6 @@ private IdleSynchronizer(DispatcherQueue dispatcherQueue)
m_rootVisualResetHandle = OpenNamedEvent(m_dispatcherQueue, s_rootVisualResetHandleName);
m_imageDecodingIdleHandle = OpenNamedEvent(m_dispatcherQueue, s_imageDecodingIdleHandleName);
m_fontDownloadsIdleHandle = OpenNamedEvent(m_dispatcherQueue, s_fontDownloadsIdleHandleName);
- m_hasBuildTreeWorksHandle = OpenNamedEvent(m_dispatcherQueue, s_hasBuildTreeWorksHandleName);
- m_buildTreeServiceDrainedHandle = OpenNamedEvent(m_dispatcherQueue, s_buildTreeServiceDrainedHandleName);
}
public static void Init()
@@ -152,8 +141,7 @@ public static void Init()
public static void Wait()
{
- string logMessage;
- Wait(out logMessage);
+ Wait(out _);
}
public static void Wait(out string logMessage)
@@ -168,8 +156,7 @@ public static void Wait(out string logMessage)
public static string TryWait()
{
- string logMessage;
- return Instance.WaitInternal(out logMessage);
+ return Instance.WaitInternal(out _);
}
public static string TryWait(out string logMessage)
@@ -193,8 +180,6 @@ public void AddLog(string message)
private string WaitInternal(out string logMessage)
{
logMessage = string.Empty;
- string errorString = string.Empty;
-
if (m_dispatcherQueue.HasThreadAccess)
{
return "Cannot wait for UI thread idle from the UI thread.";
@@ -206,11 +191,9 @@ private string WaitInternal(out string logMessage)
bool isIdle = false;
while (!isIdle)
{
- bool hadAnimations = true;
- bool hadDeferredAnimationOperations = true;
bool hadBuildTreeWork = false;
- errorString = WaitForRootVisualReset();
+ var errorString = WaitForRootVisualReset();
if (errorString.Length > 0) { return errorString; }
AddLog("After WaitForRootVisualReset");
@@ -228,6 +211,7 @@ private string WaitInternal(out string logMessage)
WaitForIdleDispatcher();
AddLog("After WaitForIdleDispatcher");
+ bool hadAnimations;
// At this point, we know that the UI thread is idle - now we need to make sure
// that XAML isn't animating anything.
// TODO 27870237: Remove this #if once BuildTreeServiceDrained is properly signaled in WinUI desktop apps.
@@ -246,6 +230,7 @@ private string WaitInternal(out string logMessage)
hadAnimations = false;
}
+ bool hadDeferredAnimationOperations;
errorString = WaitForDeferredAnimationOperationsComplete(out hadDeferredAnimationOperations);
if (errorString.Length > 0) { return errorString; }
AddLog("After WaitForDeferredAnimationOperationsComplete");
@@ -324,70 +309,6 @@ void WaitForIdleDispatcher()
shouldContinueEvent.WaitOne(s_defaultWaitForEventMs);
}
- string WaitForBuildTreeServiceWork(out bool hadBuildTreeWork)
- {
- hadBuildTreeWork = false;
- bool hasBuildTreeWork = true;
-
- // We want to avoid an infinite loop, so we'll iterate 20 times before concluding that
- // we probably are never going to become idle.
- int waitCount = 20;
-
- while (hasBuildTreeWork && waitCount-- > 0)
- {
- if (!NativeMethods.ResetEvent(m_buildTreeServiceDrainedHandle.NativeHandle))
- {
- return "Failed to reset BuildTreeServiceDrained handle.";
- }
-
- AutoResetEvent layoutUpdatedEvent = new AutoResetEvent(false);
-
- m_dispatcherQueue.TryEnqueue(
- DispatcherQueuePriority.Normal,
- new DispatcherQueueHandler(() =>
- {
- foreach (Window window in WindowHelper.ActiveWindows)
- {
- if (window.Content != null)
- {
- window.Content.UpdateLayout();
- }
- }
-
- layoutUpdatedEvent.Set();
- }));
-
- layoutUpdatedEvent.WaitOne(s_defaultWaitForEventMs);
-
- // This will be signaled if and only if Jupiter plans to at some point in the near
- // future set the BuildTreeServiceDrained event.
- uint waitResult = NativeMethods.WaitForSingleObject(m_hasBuildTreeWorksHandle.NativeHandle, 0);
-
- if (waitResult != NativeMethods.WAIT_OBJECT_0 && waitResult != NativeMethods.WAIT_TIMEOUT)
- {
- return "HasBuildTreeWork handle wait returned an invalid value.";
- }
-
- hasBuildTreeWork = (waitResult == NativeMethods.WAIT_OBJECT_0);
- AddLog("HasBuildTreeWork? " + hasBuildTreeWork);
-
- if (hasBuildTreeWork)
- {
- AddLog("Waiting for BuildTreeService to finish...");
- waitResult = NativeMethods.WaitForSingleObject(m_buildTreeServiceDrainedHandle.NativeHandle, 10000);
-
- if (waitResult != NativeMethods.WAIT_OBJECT_0 && waitResult != NativeMethods.WAIT_TIMEOUT)
- {
- return "Wait for build tree service failed";
- }
- AddLog("BuildTreeService drained");
- }
- }
-
- hadBuildTreeWork = hasBuildTreeWork;
- return string.Empty;
- }
-
string WaitForAnimationsComplete(out bool hadAnimations)
{
hadAnimations = false;
@@ -473,31 +394,6 @@ string WaitForDeferredAnimationOperationsComplete(out bool hadDeferredAnimationO
return string.Empty;
}
- private void SynchronouslyTickUIThread(uint ticks)
- {
- for (uint i = 0; i < ticks; i++)
- {
- AutoResetEvent tickCompleteEvent = new AutoResetEvent(false);
-
- m_dispatcherQueue.TryEnqueue(
- DispatcherQueuePriority.Normal,
- new DispatcherQueueHandler(() =>
- {
- EventHandler