c# - WPF Control Visibility w/ ICommand & OnPropertyChanged -


i have user window 3 controls - 'execute' button, results control, , processing control. goal display processing control after execute pressed, hide when execute method finishes.

however, processing control not display when assumed would... instead displays when (if) callback function creates window prompting user input called.

the processing control has visibility bound bool processing in viewmodel via booltovis converter. execute method sets processing true @ start, false when finishes. setter of processing calls onpropertychanged. view model implements inotifypropertychanged.

    private bool _processing;     public bool processing     {                 { return _processing; }         set         {             _processing = value;             this.onpropertychanged("processing");         }     }      private relaycommand _search;     public relaycommand search     {         { return _search ?? (_search = new relaycommand(p => onsearch(), p => cansearch())); }     }     private void onsearch()     {         this.processing = true;          dowork(delegate callback);          this.processing = false;     } 

and of xaml:

    <booleantovisibilityconverter x:key="booltovis" />      <me:processingcontrol visibility="{binding path=processing, converter={staticresource resourcekey=booltovis}}"/> 

use task or background worker dowork, set processing=true before starting task or background worker , make false @ end of task. enable processing control visible , hide. if chaining value of bool processing in task or ground worker make sure invoke via dispatcher


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -