如何在MVVM中绑定Xtended WPF Toolkit向导的CurrentPage?

5
我可以帮忙翻译。这段内容是关于编程的,作者使用了Xceed WPF Toolkit's Wizard Control来构建一个多页向导。作者需要程序知道当前活动的页面,以便确定必要的步骤。作者试图将CurrentPage与ViewModel绑定,如下所示: XAML:
<xctk:Wizard CurrentPage="{Binding CurrentStep, Mode=TwoWay}">
    <xctk:WizardPage Name="Import">
       ...
    </xctk:WizardPage>
       ...
</xctk:Wizard>

视图模型:

public WizardPage CurrentStep { get; set; }

问题在于CurrentStep始终返回Null,向导只显示空白页面。为了让MVVM使用CurrentPage返回活动的向导页面,需要做什么?
2个回答

2

如果想要绑定有效,CurrentStep 应该是一个 DependencyProperty 或者 ViewModel 应该实现 INotifyPropertyChanged 接口。


1

xaml:

<xctk:Wizard    x:Name="wizMain"
                Grid.Row="1"
                FinishButtonClosesWindow="True" 
                ItemsSource="{Binding wizardPages}" 
                Background="White"
                ExteriorPanelMinWidth="100"
                HelpButtonVisibility="Hidden"
                CanSelectNextPage="{Binding CanProceed, UpdateSourceTrigger=PropertyChanged}"
                CurrentPage="{Binding Path=CurrentWizardPage, Mode=TwoWay}"
>

从ViewModel:

public WizardPage CurrentWizardPage { get; set; }

HTH, Ray


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接