Message freezes the UI application without using the pop-up messagebox

181 Views Asked by At

We are working with WPF. And we have an application with multiple screens and a tree in the left. In one of them, the user add, edit and delete an node in that tree. So, We need to show the user a message when he press delete message, if he really wants to delete or not (Yes/Cancel) message, which it needs to freeze the whole application. Then the user is forced to decide. In the same time, we don't want a pop-up message. We need something like Adorner. Shows a gray background (which means the whole application has freezed) and we can host a border with a message inside it. We need alternatives options for Adorner.

1

There are 1 best solutions below

0
kurin123 On

You may use something like this

<Window x:Class="WpfApplication5.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
    <Grid>
        <Border Name="msg" Background="#20A0A0A0" Visibility="Hidden">
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                <Button Margin="10" Click="Button_Click_1">Yes</Button>
                <Button Margin="10" Click="Button_Click_1">No</Button>
            </StackPanel>
        </Border>
        <Border Name="main">
            <StackPanel>
                <TextBlock Text="tex"/>
                <Button Click="Button_Click">Delete</Button>
                <Button>Another button</Button>
                </StackPanel>
        </Border>

    </Grid>
</Window>

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        msg.Visibility = System.Windows.Visibility.Visible;
        main.IsEnabled = false;
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        msg.Visibility = System.Windows.Visibility.Hidden;
        main.IsEnabled = true;
    }