I have a Silverlight app that is using the MVVM pattern. I have a WCF service which will allow me to authenticate users (I don’t have direct control over that service – assume it is a black box that just returns me the user info and a list of privileges the user has). So, when the app starts up, I want to pull security data from that service.
Right now, when I do this, my views and view models can end up getting initialized before the service returns with the security data. This causes problems because the view models need to disable buttons and make things visible/invisible based on the user having certain privileges.
Is there a pattern that allows me to prevent the initialization of the views / view models until the WCF call has returned? How would you go about solving this problem as elegantly as possible?
Generally, you use
BusyIndicatorfromSilverlight Toolkitfor scenarios like this one.Instead of disabling the
UI, it shows them a progress instead.What you do is provide a
IsBusyproperty onViewModel. While loading data, set it toTrueandFalserest of the time. Wrap yourUIwith aBusyIndicatorcontrol and bind that property’s value withBusyIndicator‘sIsBusyproperty.With this in place, your
UIwill acknowledge whenever it’s busy.