|
-
November 28th, 2011, 01:26 AM
#1
BusyIndicator and UserControl
Hi
I am doing a SilverLight (4) Application. In that, I want to create a UserControl which contains a BusyIndicator. In my MainPageView.xaml, I ve included this UserControl. In MainPageViewModel constructor , i am making isBusy property to true. On button click, i want to set IsBusy to false.
How can i do this using MVVM.
Please help if anybody knows the answer
Thanks
-
January 7th, 2012, 04:56 PM
#2
Re: BusyIndicator and UserControl
You need to create a property in your ViewModel like
private bool _myControlIsBusy;
public bool MyControlIsBusy
{
get { return _myControlIsBusy; }
set
{
_myControlIsBusy = value;
RaisePropertyChanged("MyControlIsBusy");
}
}
Then you can bind the IsBusy property on your busy indicator to this property like
IsBusy = {Binding MyControlIsBusy}
As long as you let the DataContext of your UserControl be the same instance of your ViewModel as your page, your property change notification should update the BusyIndicator inside of your control because its DataContext will come from its parent (which is ultimately your UserControl).
For your button click, you can use a Command to delegate the action from the click to your ViewModel.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|