WPF Please Wait Dialog

A little lateral thinking always helps when developing WPF applications. You can fulfil your requirements easily with just a Grid, a Rectangle, a bool property (which you could already have) and a BooleanToVisibilityConverter and you won't have to disable any controls.

The idea is simple. Add a white Rectangle in front of your view content with its Opacity property set between 0.5 and around 0.75. Data bind its Visibility property to the bool property in your view model or code behind and plug in the BooleanToVisibilityConverter:

<Grid>
    <Grid>
        <!--Put your main content here-->
    </Grid>
    <Rectangle Fill="White" Opacity="0.7" Visibility="{Binding IsWaiting, 
        Converter={StaticResource BooleanToVisibilityConverter}}" />
    <!--You could add a 'Please Wait' TextBlock here-->
</Grid>

Now when you want to disable the controls, you just set the bool property to true and the Rectangle will make the UI appear faded:

IsWaiting = true;

Tags:

C#

.Net

Wpf

Wait