Is there a way to set the property of type 'Type' from xaml?
See original GitHub issueI have a WinUI/UWP project. In my custom control I have a property of type Type. I tried to set it from xaml like ControlTemplate.TargetType property, but got an exception on InitializeComponent.
Windows.UI.Xaml.Markup.XamlParseException: 'The text associated with this error code could not be found.
Failed to assign to property ‘App11.MyControl.SomeProperty’. [Line: 17 Position: 26]’
Is there a way to set such properties from xaml?
Sample control
public class MyControl : Button
{
public Type SomeProperty { get; set; }
}
Xaml
<local:MyControl SomeProperty="Button" />
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Setting a custom type property in XAML using a static ...
I'm trying to determine if there's a way to set a custom type to a property through XAML by using a static method's...
Read more >Setter.Property Property (Windows.UI.Xaml) - UWP
You can use a Setter to style an attached property. In this case the dependency property name is a qualified name in XAML...
Read more >Style.TargetType Property (Windows.UI.Xaml) - UWP
Gets or sets the type for which the style is intended. TargetType can be used to declare an implicit style resource if there's...
Read more >XAML Magic: Attached Properties
Fundamentally, the Dependency Property system is a way to first define a property and register it with the overall Dependency Property system, ...
Read more >Setting property of type System.Type in XAML doesn't set ...
The Xaml compiler generally doesn't inspect property values themselves, so it doesn't know to generate type info for a property of type System....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks! You’re right, the
Windows.UI.Xaml.Markup.XamlParseException
text displayed by VS tricked me into thinking that you were using UWP XAML rather than WinUI 3.As it turns out, this is a known issue that we’re already working on fixing, but we appreciate the report nonetheless!
This will be fixed in the WinUI 3 Preview 2 release.