I am trying to solve what looks like a simple problem, but I can’t find a simple solution. I have a window in wpf, that window contains only of one listbox with few names and one button, the button don’t do anything. When you click on an item in the listbox it creates and shows a new window (child window). At this point I want the window behind to be disabled, but I also want the look of it not to change. However the listbox and the button (or any other control I put on that window) change their colour. How do I achieve the above, in the simplest possible way?
Here is the code:
<Window x:Class="MainWindowStyleAndBehaviour.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowState="Maximized" Name="myWindow">
<Grid Background="Green">
<ListBox Name="myListbox" HorizontalAlignment="Left" VerticalAlignment="Top" Height="200" Width="300" Background="Red" FontSize="30" SelectionChanged="myListbox_SelectionChanged" Margin="10"/>
<Button Content="Don't click me" Width="300" Height="60" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="30" Margin="10"/>
</Grid>
</Window>
namespace MainWindowStyleAndBehaviour
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Names = new List<string>() { "Sonia", "Bruno", "Cezar" };
myListbox.ItemsSource = Names;
}
public List<string> Names { get; set; }
private void myListbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Window w = new Window();
myWindow.IsEnabled = false;
w.Show();
w.Closed += (s, ea) => myWindow.IsEnabled = true;
}
}
}
Thank you in advance :)