I have a border control that I am using as a loading screen overlay over my main window for when I am opening a couple large files. To do this, I am changing the visibility property of the border to Visible after the dialog box is created. The problem is that the border never actually shows up. This is the code that does not work:
var openFileDialog = new ViewerOpenFileDialog();
openFileDialog.ShowDialog();
LoadingScreen.Visibility = Visibility.Visible;
ViewerViewModel.OpenFile(openFileDialog.ParamFileName, openFileDialog.IdFileName);
LoadingScreen.Visibility = Visibility.Hidden;
After I close the dialog, the border never becomes visible.
This code DOES work, however:
LoadingScreen.Visibility = Visibility.Visible;
var openFileDialog = new ViewerOpenFileDialog();
openFileDialog.ShowDialog();
ViewerViewModel.OpenFile(openFileDialog.ParamFileName, openFileDialog.IdFileName);
LoadingScreen.Visibility = Visibility.Hidden;
The border becomes visible until after my files load, however it is visible while my dialog box is open which is not ideal.
Here is the XAML for my border:
<Border Name="LoadingScreen" Background="#80000000" VerticalAlignment="Stretch" Visibility="Hidden">
<Grid>
<TextBlock Margin="0" TextWrapping="Wrap" Text="Loading, Please Wait..." HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="30" FontWeight="Bold" />
</Grid>
</Border>
Copyright Notice:Content Author:「wilk」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24289637/changing-wpf-border-visibility-after-opening-dialog-box