I really want a Templated Control
in my UWP
app. Just like Custom Control
in WPF
, not User Control
. But I can't make it work with Visual Studio 2022
. When I add a new Templated Control
to the MainPage - app throws an exception saying
Specified cast is not valid
Can reproduce it very quickly:
- Create a new
UWP
project - Add a new
Templated Control
- MyControl.cs. That creates a control with minimal code/XAML that should suffice - In the MainPage, add
<local:MyControl/>
to the root grid - Run the app - it fails, saying 'Specified cast is not valid'
How can I fix that?