Reputation: 77
I am trying to use the WPFToolkit.Wizard in an application using the MVVM design model.
RIght now I am having difficulties binding a RelayCommand (inherits from ICommand) to the Next/Previous/Finish buttons.
I see the wizard raises events but this would break the paradigm.
The command is defined:
public ICommand NextStage
{
get
{
return _NextStage ?? (
_NextStage = new RelayCommand(param => PrepNextStep(),
param => Page((PageIndexes)CurrentStage).IsDirty
));
} // get
} // public ICommand NextStage
The XAML is:
<xctk:Wizard x:Name="wizMain"
Grid.Row="1"
FinishButtonClosesWindow="True"
ItemsSource="{Binding wizardPages}"
Background="White"
ExteriorPanelMinWidth="100"
HelpButtonVisibility="Hidden"
Next="{Binding Path=NextStage}"
>
</xctk:Wizard>
The error that is thrown at runtime is:
'Provide value on 'System.Windows.Data.Binding' threw an exception.' Line number '33' and line position '25'.
Any help would be greatly appreciated.
TIA, Ray
Upvotes: 0
Views: 488
Reputation: 169380
Next
is an event and not a dependency property that you can bind to an ICommand
source property.
What you could do is to add a reference to System.Windows.Interactivity.dll and use an interaction trigger to invoke your command when the wizard raises the event:
<xctk:Wizard ... xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Next">
<i:InvokeCommandAction Command="{Binding NextStage}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</xctk:Wizard>
Upvotes: 1