dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

Attached event not fire upon the first load #9659

Open ShannonZ opened 2 months ago

ShannonZ commented 2 months ago

Description

Here is a minimal reproduction project The UI structure is TabItem > StackPanel > TextBox. When the property bound to TextBox gets a validation error, the validation state should be reported to the direct parent StackPanel and then TabItem. But the Validation.Error event did not fire upon the first time adding the content to UI.

Reproduction Steps

After setting up, click the bottom Button with "Add Content". This will load a view model (ViewModel class instance with validation errors) and apply DataTemplate before rendering on UI. The Validation rules are: all the three int properties A, B, C should be larger than zero and C = A-B.

From the debug information printed in the output console, you'll find that Validation.Error was not fired. But after that, if you change the second TextBox under the first TabItem to a negative value, you'll see the Validation.Error bubbled as expected: TextBox-> StackPanel->TabItem.

Expected behavior

Attached event (Validation.Error) should fire upon the first load

Actual behavior

Attached event (Validation.Error) did not fire upon the first load

Regression?

No response

Known Workarounds

No response

Impact

No response

Configuration

No response

Other information

No response

ShannonZ commented 1 month ago

@himgoyalmicro Is there any progress?