我有一個邊框控件,我用它作爲加載屏幕疊加在我的主窗口上,當我打開幾個大文件時。爲此,我在創建對話框後將邊框的可見性屬性更改爲Visible。問題是邊界從來沒有真正顯示出來。這是不起作用的代碼:打開對話框後更改WPF邊框的可見性
var openFileDialog = new ViewerOpenFileDialog();
openFileDialog.ShowDialog();
LoadingScreen.Visibility = Visibility.Visible;
ViewerViewModel.OpenFile(openFileDialog.ParamFileName, openFileDialog.IdFileName);
LoadingScreen.Visibility = Visibility.Hidden;
在關閉對話框後,邊框永遠不可見。
此代碼的工作,但是:
LoadingScreen.Visibility = Visibility.Visible;
var openFileDialog = new ViewerOpenFileDialog();
openFileDialog.ShowDialog();
ViewerViewModel.OpenFile(openFileDialog.ParamFileName, openFileDialog.IdFileName);
LoadingScreen.Visibility = Visibility.Hidden;
邊界變得直到我的文件,加載後可見,但同時我的對話框打開這是不理想的是可見的。
這裏是我的邊境XAML:
<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>
爲什麼不自定義忙指標的樣式模板? –
您是否嘗試開始打開文件並將加載屏幕可見性設置爲隱藏的新線程?這應該給UI線程時間來使加載屏幕可見。 – Slade