RadBusyIndicator Not Showing in MVVM App

15 posts, 0 answers
  1. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 28 Jan 2011 Link to this post

    Trying to display a RadBusyIndicator in an WPF MVVM application however the control does not appear when IsBusy binding occurs.

    Here is a portion of what is in the user control xaml...

    <Grid>
      <telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" Grid.Row="0" >
        <Grid>
          <StackPanel Margin="10,10,10,10">
              ...some content here...                 
          </StackPanel>
        </Grid>
      </telerik:RadBusyIndicator>
    </Grid>

    I bind the IsBusy to a property in my ViewModel, set the property to true, and then fire OnPropertyChanged to rebind the view. Unfortunately the BusyIndicator does not show.

    Has anyone experienced this challenge before, and if so, what was done to resolve it?

    I'll follow up this post with an example solution that recreates the problem. Until then, let me know if you have any insights into this.

    Cheers, 

    Paul
  2. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 28 Jan 2011 Link to this post

    Solved it!

    Built an async specific delegate command for my ViewModel and then hooked into that to update the IsBusy binding. Even threw in some view navigation with a RadTransitionControl cherry on top! All is good :)

    If you are curious how this was all put together, let me know and I'll post about it on my blog. (Ah, I'll post about it anyway otherwise I'll forget what I did :P )

    Cheers!
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andreas Lindahl
    Andreas Lindahl avatar
    2 posts
    Member since:
    Feb 2010

    Posted 02 Feb 2011 Link to this post

    Hi Paul,

    I am very interested in your solution so please do post it on your blog if possible.

    Thanks in advance!
  5. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 02 Feb 2011 Link to this post

    Hi Andreas,

    I am working on it right now (www.PaulSPatterson.com). 

    Cheers!
  6. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 03 Feb 2011 Link to this post

    Hi Paul
    I am working on MVVM pattern with Command in Silverlight can you please share with me how did u utilize busyIndicator in MVVM.
    i will appriciate your work.
  7. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 03 Feb 2011 Link to this post

    I'll be posting a full example on my blog (soon). Until then, check out this article by Anoot Madhusudanan here. http://amazedsaint.blogspot.com/2010/10/asynchronous-delegate-command-for-your.html . 

    What I did was, when the async command is executed, the delegate action updates a boolean property (which happens to be named isBusy) in the ViewModel to true. When the async command is done, the isBusy property is set back to false.

    For example, in my ViewModel...

    Namespace ViewModels
      Public Class UserLoginViewModel
        Inherits ViewModelBase
     
        Private _isBusy As Boolean = False
     
        Public Property IsBusy As Boolean
            Get
                Return _isBusy
            End Get
            Set(ByVal value As Boolean)
                _isBusy = value
               OnPropertyChanged("IsBusy")
            End Set
        End Property
     
        Public Property LoginAsyncCommand As ICommand
            
        Public Sub New(ByVal regionManager As IRegionManager, ByVal container As IUnityContainer)
     
           Dim loginAction As Action = New Action(AddressOf LoginExecute)
           LoginAsyncCommand = New AsyncDelegateCommand(loginAction, Nothing, Sub() LoadView())
     
         End Sub
     
      Private Sub LoginExecute()
           If IsBusy Then
             Exit Sub
           End If
            IsBusy = True
            ' Do some login stuff here...
                 IsBusy = False
     End Sub
     
       Public Sub LoadView()
            Try
                    If _loginSuccess Then
                    '   Do some view management here.
                    End If
                Catch ex As Exception
                    LoginSuccess = ex.Message
                End Try
            End Sub
     
       End Class
    End Namespace

    AsyncDelegateCommand is a class that is the same that Anoot wrote about.

    In the View...
    <Grid>
      <telerik:RadBusyIndicator IsBusy="{Binding IsBusy}" Grid.Row="0">
        <Grid>
          <StackPanel>
            <!-- Some content here.... -->
            <Button x:Name="LoginCommand" Content="Login..."  Command="{Binding LoginAsyncCommand}"/>
          </StackPanel>
        </Grid>
      </telerik:RadBusyIndicator>
    </Grid>

    I have a lot more happening in there of course - with Prism and all, but this should get you started.

    - Cheers

     


  8. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 03 Feb 2011 Link to this post

    Thanks Paul for your Quick reply.
  9. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 11 Feb 2011 Link to this post

    Hello,

    As promisied, here is the link to the blog posting on how I implemented an asynchronous command delegate to achieve the RadBusyIndicator in an MVVM application. 

       www.PaulSPatterson.com

    Cheers!
  10. Teodor
    Admin
    Teodor avatar
    501 posts

    Posted 16 Feb 2011 Link to this post

    Hello Paul,

    Please refer also to this online demo to see RadBusyIndicator in a MVVM scenario with proper behavior when changing the IsBusy property. 

    Hope this will be of use. We will be glad to assist you further.

    Regards,
    Teodor
    the Telerik team
  11. Paul Patterson
    Paul Patterson avatar
    40 posts
    Member since:
    May 2010

    Posted 16 Feb 2011 Link to this post

    I was able to resolve this already (as per the link I provided earlier). Thanks anyway.
  12. Andreas Lindahl
    Andreas Lindahl avatar
    2 posts
    Member since:
    Feb 2010

    Posted 16 Feb 2011 Link to this post

  13. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 16 Feb 2011 Link to this post

    Hi,

     I've just tried the demo an it works as expected. You can check the attached screenshot. 

    Regards,
    Vlad
    the Telerik team
  14. Mark
    Mark avatar
    24 posts
    Member since:
    Jan 2011

    Posted 29 Aug 2011 Link to this post

    I would be interested. I glanced at your website and didn't see it.

    -Markus
  15. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 01 Sep 2011 Link to this post

    Hello Markus,

    You can also get the link for the demos from the WPF products' page: http://www.telerik.com/products/wpf.aspx

    Kind regards,
    Konstantina
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  16. Rob
    Rob avatar
    1 posts
    Member since:
    Sep 2014

    Posted 25 Jul in reply to Paul Patterson Link to this post

    fyi - this is a few years later, following the link to Paul's site triggers my Alvira anti-virus

    "The site ahead contains malware"

     

Back to Top
UI for WPF is Visual Studio 2017 Ready