Reputation: 441
I want to open NewWindow
over Main Window in UWP and disable the background Window(MainWindow) Interaction.
What I Have Tried?
AppWindow appWindow = await AppWindow.TryCreateAsync();
Frame appWindowContentFrame = new Frame();
appWindowContentFrame.Navigate(typeof(AppWindowPage));
AppWindowPage page = (AppWindowPage)appWindowContentFrame.Content;
page.MyAppWindow = appWindow;
page.TextColorBrush = new SolidColorBrush(colorPicker.Color);
ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame);
appWindow.Title = "App Window " + AppWindows.Count.ToString();
await appWindow.TryShowAsync();
It Opens the new Window, but I want to disable the background interaction and the new Window must be closed only when a button is clicked which is present in NewWindow
.
Upvotes: 1
Views: 405
Reputation: 7727
Sorry, currently UWP does not have any API to limit the interaction of the entire window.
A more likely solution is to create a Grid
with high transparency
in the Main Window, covering all controls, thereby blocking click interaction:
<Grid>
<Grid>
<!-- Main content -->
</Grid>
<Grid x:Name="MaskGrid" Background="White" Opacity="0.01" Visibility="Collapsed"/>
</Grid>
Before calling await appWindow.TryShowAsync()
you can set MaskGrid.Visibility = "Visible"
. But this cannot restrict the keyboard to use the Tab key to switch controls.
Upvotes: 0