如何禁用 DropShadow 或 ContentDialog 的任何阴影?UWP、XAML [英] How to Disable DropShadow or any shadow of ContentDialog? UWP, XAML

查看:27
本文介绍了如何禁用 DropShadow 或 ContentDialog 的任何阴影?UWP、XAML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有自定义 xaml 样式的 ContentDialog,contentDialog 应该有圆角,但我可以看到矩形阴影......有趣的是,阴影在 Windows 1809 版本中没有显示,它在 1903 年显示.

I am using ContentDialog with a custom xaml style for it, the contentDialog is supposed to have rounded corners but I can see rectangular shadow... interestingly the shadow doesn't show in Windows 1809 build, it does in 1903.

我已经看到,当我移除容器"边框时,阴影消失了,但内容对话框不再位于页面的中心,而是位于左上角.

I have seen that when I remove the "Container" border, the shadow goes away but the content dialog is no longer in the center of the page ,it goes to top left.

我也尝试使用 Shadow 属性,并尝试将代码包装在 DropShadow 中.它不会使阴影消失.

I also tried using the Shadow property, and tried wrapping the code in DropShadow..it does not make the shadow go away.

如何从内容对话框中禁用或关闭阴影?或者,我怎样才能让阴影变圆...阴影停留...请帮忙.

How can I disable or turn off the shadow from the content dialog ? Or, how can I make the Shadow get rounded... the shadow stays...Please help.

推荐答案

在内容对话框的默认样式中,有一个名为 "BackgroundElement" 的元素,它是一个 Borderstrong> 元素,将其更改为 Grid 将移除阴影,因为阴影应用于 Border 元素.

In the default style for a content dialog there is an element named "BackgroundElement", it is a Border element, changing it to Grid will remove the shadow as the shadow is applied on the Border element.

但是,这样做会弄乱内容对话框的定位,因为显然 UWP 框架相对于应该是边框的命名元素来定位/重新定位内容对话框.但是,通过网格和一些讨厌的黑客,我们可以修复它,我们可以获取内容对话框的引用(在合适的位置),并像这样设置它的边距(只有通过设置边距我们才能真正移动/重新定位 ContentDialog:这一点知识来自大量的反复试验).这是使用边距的重新定位代码.. 一直在工作

However, doing this will mess up the positioning of the Content dialog, as apparently UWP framework positions/repositions the content dialog with respect to the named element which is supposed to be a border. But, with grid and a bit of a nasty hack, we can fix it, we could grab the reference of the Content dialog (at a suitable position), and set it's Margin like this (only by setting the margin can we really move/reposition the ContentDialog: this bit of knowledge comes from a lot of trial and error). Here's the repositioning code using margin.. that has been working

   double leftmargin = (Window.Current.Bounds.Width / 2.0) - (contentDialogReference.ActualWidth / 2.0);
   double topmargin = (Window.Current.Bounds.Height / 2.0) - (contentDialogReference.ActualHeight / 2.0);
   contentDialogReference.Margin = new Thickness(leftmargin, topmargin, 0, 0);

这篇关于如何禁用 DropShadow 或 ContentDialog 的任何阴影?UWP、XAML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆