mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-03 07:55:10 +00:00
revert content dialog work-around for titlebar overlap (#26648)
This commit is contained in:
committed by
GitHub
parent
97578a1b97
commit
0adda35b4b
@@ -1,67 +0,0 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
||||||
// See the LICENSE file in the project root for more information.
|
|
||||||
|
|
||||||
using Microsoft.UI.Xaml;
|
|
||||||
using Microsoft.UI.Xaml.Media;
|
|
||||||
|
|
||||||
namespace Hosts.Helpers
|
|
||||||
{
|
|
||||||
// Taken from https://github.com/microsoft/microsoft-ui-xaml/blob/main/test/MUXControlsTestApp/Utilities/VisualTreeUtils.cs
|
|
||||||
// Original copyright header:
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
||||||
public static class VisualTreeUtils
|
|
||||||
{
|
|
||||||
public static T FindVisualChildByType<T>(this DependencyObject element)
|
|
||||||
where T : DependencyObject
|
|
||||||
{
|
|
||||||
if (element == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element is T elementAsT)
|
|
||||||
{
|
|
||||||
return elementAsT;
|
|
||||||
}
|
|
||||||
|
|
||||||
int childrenCount = VisualTreeHelper.GetChildrenCount(element);
|
|
||||||
for (int i = 0; i < childrenCount; i++)
|
|
||||||
{
|
|
||||||
var result = VisualTreeHelper.GetChild(element, i).FindVisualChildByType<T>();
|
|
||||||
if (result != null)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FrameworkElement FindVisualChildByName(this DependencyObject element, string name)
|
|
||||||
{
|
|
||||||
if (element == null || string.IsNullOrWhiteSpace(name))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element is FrameworkElement elementAsFE && elementAsFE.Name == name)
|
|
||||||
{
|
|
||||||
return elementAsFE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int childrenCount = VisualTreeHelper.GetChildrenCount(element);
|
|
||||||
for (int i = 0; i < childrenCount; i++)
|
|
||||||
{
|
|
||||||
var result = VisualTreeHelper.GetChild(element, i).FindVisualChildByName(name);
|
|
||||||
if (result != null)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -426,7 +426,6 @@
|
|||||||
<ContentDialog
|
<ContentDialog
|
||||||
x:Name="EntryDialog"
|
x:Name="EntryDialog"
|
||||||
x:Uid="EntryDialog"
|
x:Uid="EntryDialog"
|
||||||
Loaded="ContentDialog_Loaded_ApplyMargin"
|
|
||||||
IsPrimaryButtonEnabled="{Binding Valid, Mode=OneWay}"
|
IsPrimaryButtonEnabled="{Binding Valid, Mode=OneWay}"
|
||||||
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
||||||
<ContentDialog.DataContext>
|
<ContentDialog.DataContext>
|
||||||
@@ -472,7 +471,6 @@
|
|||||||
<ContentDialog
|
<ContentDialog
|
||||||
x:Name="AdditionalLinesDialog"
|
x:Name="AdditionalLinesDialog"
|
||||||
x:Uid="AdditionalLinesDialog"
|
x:Uid="AdditionalLinesDialog"
|
||||||
Loaded="ContentDialog_Loaded_ApplyMargin"
|
|
||||||
PrimaryButtonCommand="{x:Bind UpdateAdditionalLinesCommand}"
|
PrimaryButtonCommand="{x:Bind UpdateAdditionalLinesCommand}"
|
||||||
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
using Hosts.Models;
|
using Hosts.Models;
|
||||||
using Hosts.Settings;
|
using Hosts.Settings;
|
||||||
using Hosts.ViewModels;
|
using Hosts.ViewModels;
|
||||||
using ManagedCommon;
|
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
@@ -211,20 +210,6 @@ namespace Hosts.Views
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContentDialog_Loaded_ApplyMargin(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Based on the template from dev/CommonStyles/ContentDialog_themeresources.xaml in https://github.com/microsoft/microsoft-ui-xaml
|
|
||||||
var border = Helpers.VisualTreeUtils.FindVisualChildByName(sender as ContentDialog, "BackgroundElement") as Border;
|
|
||||||
border.Margin = new Thickness(0, 32, 0, 0); // Should be the size reserved for the title bar as in MainWindow.xaml
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError("Couldn't set the margin for a content dialog. It will appear on top of the title bar.", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the keyboard shortcuts at list view level since
|
/// Handle the keyboard shortcuts at list view level since
|
||||||
/// KeyboardAccelerators in FlyoutBase.AttachedFlyout works only when the flyout is open
|
/// KeyboardAccelerators in FlyoutBase.AttachedFlyout works only when the flyout is open
|
||||||
|
Reference in New Issue
Block a user