CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    15

    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

  2. #2
    Join Date
    Jun 2009
    Posts
    10

    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
  •  





Click Here to Expand Forum to Full Width

Featured