This project has moved and is read-only. For the latest updates, please go here.

BusyIndicator: Binding / MVVM - Idicator is not shown

Feb 13, 2013 at 1:26 PM
Edited Feb 13, 2013 at 2:45 PM
I have try to integrate the BusyIndicator in my WPF Application.

I have a MainView there is only placed the BusyIndicator.

I have a ViewModel that expose a propty IsBusy.

My Model have a Command to connect to a server

I want that in the time where the login process is working the user see the BusyIndicator. But that not work in my case.

Here some code

MainView.xaml
<xctk:BusyIndicator Height="65" HorizontalAlignment="Left" Margin="147,61,0,0" Name="busyStartup" VerticalAlignment="Top" Width="156" 
                            IsBusy="{Binding Path=IsBusy}" />
LoginModel.vb
   ''' <summary>
    ''' Wie das Ergebniss der letzten Operation war, die ausgeführt wurde
    ''' </summary>
    ''' <value></value>
    ''' <returns>Es wird ein allgemeines Ergebnis erzeugt</returns>
    ''' <remarks></remarks>
    Public Property OperationStatus As OperationStatus Implements ILogin.OperationStatus
        Get
            Return _OperationStatusData.Status
        End Get
        Set(value As OperationStatus)
            If value <> _OperationStatusData.Status Then
                _OperationStatusData.Status = value
                Me.OnPropertyChanged("OperationStatus")
            End If
        End Set
    End Property

    ''' <summary>
    ''' Stellt eine Verbindung zu einem Server her, mit den Informationen, die in LoginData hinterlegt sind
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub Connect() Implements ILogin.Connect

        OperationStatus = OperationStatusEnum.OperationStatus.InProcess

        Try

...

            OperationStatus = OperationStatusEnum.OperationStatus.Success

        Catch ex As Exception
  
...

            OperationStatus = OperationStatusEnum.OperationStatus.Fail

        End Try

    End Sub
MainViewModel.vb
 Public Sub New()

        _LoginModel = New LoginModel

        AddHandler _LoginModel.PropertyChanged, AddressOf ModelPropertyChanged

    End Sub

 Public ReadOnly Property IsBusy As Boolean
        Get
            Return (_LoginModel.OperationStatus = OperationStatusEnum.OperationStatus.InProcess)
        End Get
    End Property

    Private Sub ModelPropertyChanged(sender As Object, e As PropertyChangedEventArgs)

        Select Case e.PropertyName
            Case "OperationStatus"
                Me.OnPropertyChanged("IsBusy")
            Case Else
                Me.OnPropertyChanged(e.PropertyName)
        End Select

    End Sub
The code is not complete - but the important parts

I have testet with a loop to extend the login process to check if the connection is atablish to fast - but that was not the reason. I hope someone can help me.

Edit:

I have found out that I must use a Backgroundworker