[英]How to blocked/Inactivate Uwp app title bar due to show ContentDialog?
I need to blocked/Inactivate whole Uwp app with title bar due to show ContentDialog.由于显示 ContentDialog,我需要阻止/停用带有标题栏的整个 Uwp 应用程序。 I have used the code from Microsoft XAML Controls Gallery App, Whereas Control-Gallery app properly blocked the whole application but my test app is not blocking the app.
我使用了 Microsoft XAML Controls Gallery App 的代码,而 Control-Gallery 应用程序正确阻止了整个应用程序,但我的测试应用程序没有阻止该应用程序。
This is another screen shoot after adding winui:XamlControlsResources ControlsResourcesVersion="Version2"
in Resource dictionary.这是在资源字典中添加
winui:XamlControlsResources ControlsResourcesVersion="Version2"
之后的另一个屏幕截图。 Which can also be achieved by overriding SystemControlPageBackgroundMediumAltMediumBrush
.这也可以通过覆盖
SystemControlPageBackgroundMediumAltMediumBrush
来实现。
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#000000" Opacity="0.18"/>
Or或者
<Application
x:Class="App2.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App2"
xmlns:winui="using:Microsoft.UI.Xaml.Controls">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<winui:XamlControlsResources ControlsResourcesVersion="Version2" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Here is the used sample code:这是使用的示例代码:
<Page
x:Class="App2.ContentDialogContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<!-- Content body -->
<TextBlock Text="Lorem ipsum dolor sit amet, adipisicing elit." TextWrapping="Wrap" />
<CheckBox Content="Upload your content to the cloud." />
</StackPanel>
</Page>
Button click:按钮点击:
private async void button_Click(object sender, RoutedEventArgs e)
{
ContentDialog dialog = new ContentDialog();
dialog.Title = "Save your work?";
dialog.PrimaryButtonText = "Save";
dialog.SecondaryButtonText = "Don't Save";
dialog.CloseButtonText = "Cancel";
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.Content = new ContentDialogContent();
var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
//DialogResult.Text = "User saved their work";
}
else if (result == ContentDialogResult.Secondary)
{
//DialogResult.Text = "User did not save their work";
}
else
{
//DialogResult.Text = "User cancelled the dialog";
}
}
I have used ExtendViewIntoTitleBar
, but the problem remains with title bar's system button area.我使用
ExtendViewIntoTitleBar
,但问题仍然存在于标题栏的系统按钮区域。
As Sir Rufo said, your expected view has been set ExtendViewIntoTitleBar
as true that could extend your view content into title bar.正如 Rufo 爵士所说,您的预期视图已将
ExtendViewIntoTitleBar
设置为 true,这可以将您的视图内容扩展到标题栏中。 and it could make whole current view content block by ContentDialog
.它可以使整个当前视图内容被
ContentDialog
阻止。
For using ExtendViewIntoTitleBar
, please refer to Title bar customization . ExtendViewIntoTitleBar
的使用请参考标题栏自定义。
var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
coreTitleBar.ExtendViewIntoTitleBar = true;
Update更新
You need to set your title bar button background color as transparent.您需要将标题栏按钮背景颜色设置为透明。
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.