Tracking property changes

dnogin's Avatar


17 Sep, 2018 02:37 AM

I would like to enable a given wizard page when all preceding pages are valid. Here is my view model:

public class Wizard
    [Child, AggregateAllChanges] 
    public AdvisableCollection<Page> Pages { get; } = new AdvisableCollection<Page>();

Here is the Page itself:

public class Page : INotifyPropertyChanged
    [Parent] Wizard Wizard { get; set; }
    public string Name { get; set; }
    public bool Valid { get; set; }

    public bool Enabled

            return Wizard.Pages
                .TakeWhile(p => p != this)
                .All(p => p.Valid);

    public event PropertyChangedEventHandler PropertyChanged = delegate { };
    void OnPropertyChanged(string propertyName)
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        if (Wizard != null)
            NotifyPropertyChangedServices.SignalPropertyChanged(Wizard, nameof(Wizard.Pages));

I was expecting PostSharp to notify about Enabled property change when Wizard.Pages changes. It does not work unfortunately – there is no updates to Enabled properties. What is wrong about this code?

XAML to test:

        <local:Page Name="First"/>
        <local:Page Name="Second"/>
        <local:Page Name="Third"/>
        <local:Page Name="Forth"/>
<ListBox ItemsSource="{Binding Pages}">
        <DataTemplate DataType="{x:Type local:Page}">
            <CheckBox Content="{Binding Name}" IsChecked="{Binding Valid}" IsEnabled="{Binding Enabled}"/>
  1. Support Staff 1 Posted by PostSharp Techn... on 19 Sep, 2018 08:08 PM

    PostSharp Technologies's Avatar
  2. PostSharp Technologies closed this discussion on 19 Sep, 2018 08:08 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac