如何解决UWP ContentDialog覆盖整个页面
当path = uiautomation.EditControl(Name = "File name:")
path.SetFocus()
path.SendKeys(file) #file=filepath
btn = uiautomation.ButtonControl(Name = "Open")
btn.SetFocus()
fil = uiautomation.EditControl(Name="File name:")
fil.SetFocus()
fil.SendKeys('{Enter}')
与Fluent XAML Theme Editor中的颜色主题一起使用时,内容对话框将覆盖整个页面
要复制,请按照以下步骤操作:
- 创建新的UWP应用
- 使用Fluent XAML Theme Editor中的配色方案并将其添加到您的项目中
- 在App.Xaml中添加以下内容:
ContentDialog
- 将
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Dictionary1.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
和TextBlock
事件添加到Loaded
- 将
MainPage
通话添加到ContentDialog
事件
Loaded
- 运行该应用程序,看看
private async void Page_Loaded(object sender,Windows.UI.Xaml.RoutedEventArgs e) { ContentDialog noWifiDialog = new ContentDialog { Title = "No wifi connection",Content = "Check your connection and try again.",CloseButtonText = "Ok" }; _ = await noWifiDialog.ShowAsync(); }
如何掩盖ContentDialog
。如果删除颜色主题,则不会发生。
解决方法
您所描述的不是对话框覆盖,而是Content Dialog框的常规背景调光功能。
Fluent XAML主题编辑器的输出仅更改了将默认背景设为纯色的样式,即我的主题为白色,但我希望用户仍然在背景中看到内容。
这是您需要管理的样式键:
SystemControlPageBackgroundMediumAltMediumBrush
将此代码段添加到在引用主主题文件后 应用的资源字典中,它将为所有内容对话框将背景设置为不透明颜色,以这种方式进行定义将允许您要在深色或浅色模式下支持不同的背景色,此示例对每个主题使用相同的颜色,但演示了如何定义不同的背景色:
<!-- override the Dialog Background -->
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="#99FFFFFF" />
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
<StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
<StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
您可以内联执行此操作,也可以将其移至另一个文件:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Dictionary1.xaml"/>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="#99FFFFFF" />
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
<StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{ThemeResource SystemColorHighlightColor}" />
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
<StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。