c# - Changing WPF border visibility after opening dialog box -
c# - Changing WPF border visibility after opening dialog box -
i have border command using loading screen overlay on main window when opening couple big files. this, changing visibility property of border visible after dialog box created. problem border never shows up. code not work:
var openfiledialog = new vieweropenfiledialog(); openfiledialog.showdialog(); loadingscreen.visibility = visibility.visible; viewerviewmodel.openfile(openfiledialog.paramfilename, openfiledialog.idfilename); loadingscreen.visibility = visibility.hidden;
after close dialog, border never becomes visible.
this code 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 files load, visible while dialog box open not ideal.
here xaml 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>
i assume that, if close dialog, wpf form needs render controls, because openfiledialog covers parts of wpf window. if set visibility codebehind need tell window, has render area again.
so might seek call:
loadingscreen.invalidate(true);
after setting visibility in first example.
since utilize wpf there might improve solution.
expecting first illustration in viewmodel of window add together property backingfield , implement inotifypropertychanged
(and of course of study set datacontext):
private visibility _loadscreenvisibility; public visibility loadscreenvisibility { { homecoming _loadscreenvisibility; } set { _loadscreenvisibility = value; onpropertychanged("loadscreenvisibility"); } }
in xaml can use
<border visibility="{binding path=loadscreenvisibility, updatesourcetrigger=propertychanged}" ... > <... /> </border>
c# .net wpf xaml
Comments
Post a Comment