Reputation: 69
I have a class with public DownloadAsync Method inside, that downloads Content over Webclient. I create an Object of that class and call the download Method.
My problem is: I would like to block Elements on UI (e.g. Buttons) until the download is done. I could not find any solution so far.
One Idea is: I could call a MessageBox with message like "download is done" in the Downloadcomplete Method and to call somehow an Eventhandler for MessageBox. But how?
Any idea how to solve my problem?
EDIT: I know hot to disable Elements, but because of asynchronuous download in the download method, I don't know when the download is over in order to enable back the elements
Upvotes: 0
Views: 226
Reputation: 6653
add an event to your data class, and when the download has finished then trigger the event handler.
then in your page do something like this in your initialiser
BusyMessage.Visibility = Visibility.Visible;
this.DataContext = MYDownloaderClass.downloadedData;
MyDownloaderClass.hasFinished += new EventHandler(hasFinished);
}
void hasFinished(object sender, EventArgs e){
BusyMessage.Visibility = Visibility.Collapsed
}
Upvotes: 1
Reputation: 9478
Try a busy indicator with an overlay. http://www.minddriven.de/index.php/technology/dot-net/windows-phone/wp7-xaml-viewmodel-busy-indicator
Upvotes: 0
Reputation: 31724
You should just disable all the elements - set IsEnabled to false on buttons etc. If you want a quick and dirty solution - you can overlay the screen with a Rectangle, Border, Grid or Popup.
Upvotes: 0