WPF Avalon Wizard Binding Error

I am using Avalon Wizard , I have many pages, but only 2 give me problems, so they will be all included:

<Grid Name="MainGrid">
  <w:Wizard Name="MyWizard"
            w:Designer.PageIndex="0"
            DataContext="{Binding ElementName=MainGrid, Path=DataContext.Policy}">
    <w:WizardPage Header="Main Member"
                  MaxHeight="600"
                  AllowNext="{Binding ElementName=MainGrid, Path=DataContext.CanContinue}"
                  Name="MainPage">
      <w:WizardPage Name="DeductionPage"
                    Header="Policy Details"
                    AllowNext="{Binding ElementName=MainGrid, Path=DataContext.CanContinue}">

      

Now for this problem, resolve the following on the master page works fine, but then on the Deduction page the next button is always available even though the CanContinue property is false!

Note that CanContinue

only false is set on load of the second page .

    private bool canContinue;
public bool CanContinue
{
  get { return canContinue; }
  set
  {
    canContinue = value;
    NotifyPropertyChanged("CanContinue");
  }
}

      

-

UPDATE

I looked at the output window and found the following exception:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=MainGrid'. BindingExpression:Path=DataContext.CanContinue; DataItem=null; target element is 'WizardPage' (Name='DeductionPage'); target property is 'AllowNext' (type 'Boolean')

      

This is happening on the page where my problem is, but why would it only be a problem on the second page? The first and second pages are tied to the same thing and the first page works great!

The problem lies in all pages except the first page, all of them are the same Master at the same level.

Any suggestions?

+3


source to share


1 answer


Not seeing the code for CanContinue

is a bit of a guess. However, in these cases, the culprit is usually due to a property that does not raise the INotifyPropertyChanged event . In your case, the property CanContinue

should raise the INotifyPropertyChanged event.

Essentially, whenever a value needs to be evaluated CanContinue

, the INotifyPropertyChanged value must be raised. This will signal to the UI that the value CanContinue

has changed and the UI should re-evaluate the bindings.



Often times, INotifyPropertyChanged is created outside of the property itself. For example, when a method is doing some work, which leads to the need to make sure that the UI is still properly bound. In your case, it might be when navigating between pages.

0


source







All Articles