If the main WPF window creates a modeless window with no assigned owner, and then it creates a modal window, why does the modeless window get disabled? Here's a code snippet that illustrates the problem.
The xaml:
<Window x:Class="ModalTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow">
<Button Content="Show modal window" Click="buttonShowModalWindow_OnClick" />
The code behind:
using System.Windows;
using System.Windows.Controls;
namespace ModalTest
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
var modelessWindowWithNoOwner = new Window { Content = new TextBlock { Text = "modeless window" } };
modelessWindowWithNoOwner.Show();
}
private void buttonShowModalWindow_OnClick(object sender, RoutedEventArgs e)
{
var modalWindowWithOwner = new Window { Owner = this, Content = new TextBlock { Text = "modal window" } };
modalWindowWithOwner.ShowDialog();
}
}
}
Thanks!