How to implement "Please Wait" screen in Silverlight - silverlight

I have developed a Silverlight application. It has a button and once it is clicked the application starts doing something which takes time. Since everything in Silverlight is asynchronous the UI is not lagging, however, I would like to add some animation to it or something else to indicate that the application is actually doing some work and that the user should wait.
I don't know how to implement this, neither thread nor XAML wise. What is the best approach to this? Thanks.

Silverlight 4 wait/spinner control
Or if you are using MVVM
Generally Preferred Method for a 'Wait' Screen using MVVM and Silverlight
You can get the busy indicator control out of the Silverlight Toolkit:
http://silverlight.codeplex.com/

Related

WPF Multiple Instances of Windows and MVVM

How do I use multiple windows in an WPF MVVM app?
I have a Main Window with a menu control that needs to open up new instances of the window each time the item it is selected. I need to be able to show windows next to each other, it is a requirement and not page or usercontrol navigation.
Does anyone have an example of doing this?
I've read it is not recommended UI design but it is the requirement I have to implement.
Actually I have this working by using the WindowManager from Caliburn.Micro which seems like an very excellent framework for this type of application. I did look into prism but it seems over complicated and Caliburn is very easy to understand which did meet the requirements. I looked into MVVM Light but the documentation is horrible and lacks examples and I don't have time to figure it out.

WPF - When application Loads, do not steal Focus from any another application

I have a simple WPF application. When it loads and I am typing in any other application (like Word or IM), my WPF app steals the focus - screwing up my typing, of course. Now, this is the very behavior I find annoying in other applications. How can I prevent this behavior?
Thank you.
Setting ShowActivated = false on your window prior to calling Show() should accomplish what you want.

WPF repaint issue

I am having an issue with repaint of my WPF control.
The WPF control is added as an ElementHost.Child for a Windows form.
When Windows 7 goes into powersave mode and is brought back to normal (by moving the mouse or key press on keyboard), the rest of Windows form controls are repainted, however the WPF part is not repainted(and the Win 7 background is visible in that area).
On Minimize and maximise of the application, the WPF part is repainted.
Anyone has any idea about this problem?
The solution for this issue was provided in MSDN magazine a while back. It shows how you can make your WPF applications "power-aware" i.e. respond to power notifications. It's an amazing article and a "must-read".
Check this link: Make Your WPF Apps Power-Aware
You can browse the source code online or download it from here: Code for PowerAware
Technologies used:
WPF
.Net Framework 3.0
Windows Vista / Windows XP
Generally, in windows forms calling .Invalidate() on a Control will cause it to repaint itself (via setting the entire control's validation rect to "dirty" and then letting it invoke its own paint event asynchronously. -- If you just invoke the Paint method in winforms without Invalidating first, you will only be able to redraw the portion that was previously marked as dirty -- as windows uses the Dirty Rectangles approach to save on redraw time.)
Hopefully you can either call .Invalidate() on your WPF host control or just call .Invalidate() on the form itself (e.g. "this.Invalidate();")
Enabling double buffering on your form might also help, but I am unsure of this -- it's worth the experiment though.
#Hasan above gave you part of the answer -- how to hook into the windows message pump which and receive windows power event notifications -- but by itself will not cause your window to be repainted (at least from what I can tell) -- it's more of a notification that says "hey, you're about to have that problem you hate. Sucks to be you."
So this is probably as simple as hooking into Hasan's message pump stuff and then calling "this.Invalidate();" any time a power event notification is received. Though that solution may be a little bit overkill.
If that's not enough you may have to tell the WPF control itself to Invalidate... which it can't do, because it doesn't have that method. The documentation suggests that .InvalidateVisual() is the equivalent, but my experience has lead me to believe otherwise. Other than invalidating at the winform's level, I can't help you. If you find the answer, please post it!

wpf WindowsFormHost

Hi Every Body
Am Working With WPF Application
I Needed To Use MS Reports In My Application So I Used WindowsFormsHost
But The Problem Is That The WindowsFormsHost Can'nt Handle Touch Events
How I Can Handle Touch Events In My Report In WindowsFormsHost
Please I Need Ur Help
Thanks
The question is as old as multi touch. As long as the control doesn't support it, you have to trick. Whether that's going to work depends on the control. The BING map control was successfully made to respond to touches. I think there's a touch enabled layer that takes touches and translates them to window messages. This can get a real mess.
Please keep in mind, that even if you can get such a solution to work, you won't get a touch optimized control. The control will probably have a bad, bad user experience...
If it's all about displaying data, I've described a possible alternative implementation on my post: for answer How to display a PDF document in a Microsoft Surface application?

Missing Unload event in Silverlight 2

Silverlight 2 is missing the unload event for a UserControl. Has anyone implemented a workaround for this?
you might want to look here:
http://gallery.expression.microsoft.com/en-us/SLUnloadedBehavior
The code is for SL 3 but if you remove the behavior code it should work for Sl2
#KeithMahony
One scenario is that you want to prevent event memory leaks, one of the pitfalls of silverlight development that most people tend to ignore.
I think the closest you'll get is Application Services which let you detect when the Silverlight application is closing and respond to it. If you're using a Navigation application then you can hook into the Navigating event of the parent frame to determine that the page is "unloading".
What are you trying to do that requires a UserControl to respond to an unloading event?
Consider using Silverlight 4. I comes with - at last - an Unloaded event.

Resources