Everything was fine until the event handler was added. When I select the (named) control and click the lightning button on the property window following message appears
"The document item has no code-behind file. Add a code-behind file and a class definition before adding event handlers.
To reproduce that behaviour you just need to run that VM without any changes to the VS 2022 installation.
When I select the (named) control and click the lightning button on the property window following message appears:
"The document item has no code-behind file. Add a code-behind file and a class definition before adding event handlers.
Its working fine on my VS Community 2022, How are you creating the Window? Are you right clicking the project → Add → New Item → (If on the compact view, then click Show all Templates) → PowerShell WPF Window → Add.