1

I have a button on an AppBar which I have set to become enabled when a property in the ViewModel becomes true. For some reason the IsEnabled binding is only being checked the first time the AppBar is shown. Have I missed something?

Here is my button XAML in the View (AppBar xaml omitted for clarity):

<Button  Style="{StaticResource DocumentAppBarButtonStyle}" AutomationProperties.Name="Approve" 
  Command="{Binding ApproveTimesheetCommand, Mode=OneWay}" 
  IsEnabled="{Binding IsAbleToProcessTimesheet, Mode=OneWay}" />

And here is my property in the ViewModel:

public bool IsAbleToProcessTimesheet
{
    get
    {
        return SelectedTimesheets.Count() > 0;
    }
}

Setting a breakpoint on the property shows that it is only called the first time the App Bar is shown. Subsequent calls to show the App Bar don't fire checks to the IsEnabled property.

Do you need to set something to get the XAML to call the property each time the AppBar is shown?

Any help would be appreciated.

Sico
  • 1,183
  • 1
  • 10
  • 16
  • You have to notify of the property change somewhere so the UI gets refreshed. Preferably in the same place you change the collection. – Patryk Ćwiek Aug 23 '13 at 13:42

1 Answers1

1

You must to define SET for IsAbleToProcessTimesheet with SetProperty method. You can inherit from abstract class BindableBase with INotifyPropertyChanged

Ilya Klementiev
  • 593
  • 8
  • 12