I need to blocked/Inactivate whole Uwp app with title bar due to show ContentDialog. 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.
This is another screen shoot after adding winui:XamlControlsResources ControlsResourcesVersion="Version2"
in Resource dictionary. Which can also be achieved by overriding 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.
As Sir Rufo said, your expected view has been set ExtendViewIntoTitleBar
as true that could extend your view content into title bar. and it could make whole current view content block by ContentDialog
.
For using ExtendViewIntoTitleBar
, please refer to Title bar customization.
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;