Validation is only displayed on the first WizardPage

Open
#1,764 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
desktop

Research direction

Reproduce the issue with the provided XAML and MainWindow code-behind, navigating between WizardPage instances and returning to the first page. Start by inspecting the Wizard and WizardPage navigation and validation lifecycle. Done means validation messages appear on every page and are re-triggered when revisiting a page.

Written by the indexing model from the issue text.

Description

Validation is done correctly on the first page of a wizard the first time it is displayed. If you then go to the next page no validation is displayed on any of the following pages, also if you go back to the first page, it does not re-do the validation.

XAML

<Window x:Class="XceedWizardValidation.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:XceedWizardValidation" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800" x:Name="window" DataContext="{Binding ElementName=window}">
    <xctk:Wizard Name="Wizard">

        <xctk:WizardPage x:Name="Page1" Title="Page1">
            <StackPanel>
                <TextBlock>This field is always wrong</TextBlock>
                <TextBox Text="{Binding Path=MyTest, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"/>

                <TextBlock FontSize="15" Margin="0,50,0,0">Go to the next wizardpage, then come back to this one.</TextBlock>
                <TextBlock FontSize="15">Bug: Validation is only performed on the first page of the wizard the first time it is seen.</TextBlock>
            </StackPanel>
        </xctk:WizardPage>

        <xctk:WizardPage x:Name="Page2" Title="Page2">
            <StackPanel>
                <TextBlock>This field also has an error, but its never displayed.</TextBlock>
                <TextBox Text="{Binding Path=MyOtherTest, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"/>
            </StackPanel>
        </xctk:WizardPage>

    </xctk:Wizard>

</Window>

Code behind

public partial class MainWindow : Window, IDataErrorInfo, INotifyPropertyChanged
{
    private string _myTest = "Some Value";
    private string _myOtherTest = "Some Value";

    public MainWindow()
    {
        InitializeComponent();
    }

    public string MyTest
    {
        get { return _myTest; }
        set
        {
            _myTest = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyTest)));
        }
    }


    public string MyOtherTest
    {
        get { return _myOtherTest; }
        set
        {
            _myOtherTest = value;
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyOtherTest)));
        }
    }

    #region IDataErrorInfo Implementation
    public string Error { get { return ""; } }

    public string this[string columnName]
    {
        get
        {
            if (columnName == nameof(MyTest))
                return "Its all wrong, try harder.";
            if (columnName == nameof(MyOtherTest))
                return "Its all wrong, try harder.";
            return "";
        }
    }
    #endregion

    public event PropertyChangedEventHandler? PropertyChanged;
}

image

After re-visiting the page

image

Dominant language
C#
Stars
4.2k
Forks
912
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xceedsoftware/wpftoolkit

All issues in xceedsoftware/wpftoolkit

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.