【问题标题】:How to bind Xtended WPF Toolkit Wizard's CurrentPage in MVVM?如何在 MVVM 中绑定 Xtended WPF Toolkit Wizard 的 CurrentPage?
【发布时间】:2018-02-02 17:39:01
【问题描述】:

我已经使用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 并且向导只显示一个空白页。

为了让CurrentPage 使用 MVVM 返回活动向导页面需要做什么?

【问题讨论】:

    标签: c# wpf mvvm wizard wpftoolkit


    【解决方案1】:

    CurrentStep 应该是一个 DependencyProperty 或 ViewModel 应该实现 INotifyPropertyChanged,否则绑定将不起作用。

    【讨论】:

      【解决方案2】:

      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, 雷

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-06-19
        • 2011-03-14
        • 1970-01-01
        • 1970-01-01
        • 2011-02-20
        • 2014-12-04
        • 1970-01-01
        相关资源
        最近更新 更多