Programmer
Programmer

Reputation: 381

OnNext event for wizard on WPF toolkit package

I'm using by WPF toolkit package for wizard class. From one Page I would like to jump to another Page based on selection of radio button (If click on Yes, so go from Page 3 to Page 4, otherwise, means, click on No radio button, so go from Page3 to Page5) I saw there is no OnNext event, but there is property called NextPage. I tried do:

On .xaml:
 <xctk:WizardPage.NextPage>
            <MultiBinding Converter="{StaticResource NextPageSelectionFromPage3}">
                <Binding ElementName="yesForBAM" Path="IsChecked" Mode="OneWay"/>
                <Binding ElementName="noForBAM" Path="IsChecked" Mode="OneWay"/>
            </MultiBinding>
        </xctk:WizardPage.NextPage>

On .xaml.cs:
public class NextPageSelectionFromPage3 : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (values[0] is bool && values[1] is bool)
            if ((bool)values[0])
                return "Page4";
        return "Page5";

    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

Any ideas how to implement dependency OnNext event?

Thanks!

Upvotes: 1

Views: 1055

Answers (1)

Anton Danylov
Anton Danylov

Reputation: 1491

Problem with your converter is that you return string, while NextPage property is of type WizardPage. But you can do this with Triggers in pure XAML, without need of converters:

        <xctk:WizardPage>
            <xctk:WizardPage.Style>
                <Style TargetType="{x:Type xctk:WizardPage}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding IsChecked, ElementName=yesForBAM}" Value="True">
                            <Setter Property="NextPage" Value="{Binding ElementName=page4}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsChecked, ElementName=noForBAM}" Value="True">
                            <Setter Property="NextPage" Value="{Binding ElementName=page5}" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </xctk:WizardPage.Style>


            <StackPanel Orientation="Vertical">
                <TextBlock Text="3" />
                <RadioButton Name="yesForBAM" Content="Show 4 page" IsChecked="True"/>
                <RadioButton Name="noForBAM" Content="Do not show 4 page"/>
            </StackPanel>
        </xctk:WizardPage>

        <xctk:WizardPage Name="page4">
            <TextBlock Text="4" />

        </xctk:WizardPage>

        <xctk:WizardPage Name="page5">
            <TextBlock Text="5" />
        </xctk:WizardPage>

Or with converter. Main idea is still that you should return WizardPage, not string.

C#

public class NextPageSelectionFromPage3 : IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (values[0] is bool && values[1] is bool)
            if ((bool)values[0])
                return values[2];

        return values[3];
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

XAML

            <xctk:WizardPage.NextPage>
                <MultiBinding Converter="{StaticResource NextPageSelectionFromPage3}">
                    <Binding ElementName="yesForBAM" Path="IsChecked" Mode="OneWay"/>
                    <Binding ElementName="noForBAM" Path="IsChecked" Mode="OneWay"/>
                    <Binding ElementName="page4" Mode="OneWay"/>
                    <Binding ElementName="page5" Mode="OneWay"/>
                </MultiBinding>
            </xctk:WizardPage.NextPage>

Upvotes: 2

Related Questions