-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting property of type System.Type in XAML doesn't set the property #4161
Comments
@RealTommyKlein FYI |
@azchohfi - thanks for the report. To use
It may work without the |
Hey @RealTommyKlein , thanks for the quick reply. That does indeed fixes the issue. If this is not supported, we need to change our strategy there, since we are using those types to parse the Microsoft Graph calls. |
@RealTommyKlein we don't own the underlying type though. It's just a .NET type we're getting from an external library. The documentation for
We're not even trying to do any Binding here, we're just trying to resolve the Type class to set as the value of the property. Is this a .NET Native issue with the type being optimized out in Release mode instead? Don't DataTemplates still work with |
@michael-hawker - the root issue is the Xaml compiler doesn't know to generate type information about
The Xaml compiler generally doesn't inspect property values themselves, so it doesn't know to generate type info for a property of type While this isn't a binding scenario, the
Which would cause the Xaml compiler to also generate the needed type info for DataTemplates work with |
@RealTommyKlein I've used this before and it was working when I shipped XAML Studio to the store back on Jan 4, 2020. So this seems like a 'recent' regression (we've been moving these prototypes of From XAML Studio in my XAML I shipped to the store: <future:SwitchPresenter Value="{x:Bind HistoryFilter, Mode=OneWay}" TargetType="models:XamlBindingInfo"> In SwitchPresenter: public Type TargetType
{
get { return (Type)GetValue(DataTypeProperty); }
set { SetValue(DataTypeProperty, value); }
}
// Using a DependencyProperty as the backing store for DataType. This enables animation, styling, binding, etc...
public static readonly DependencyProperty DataTypeProperty =
DependencyProperty.Register(nameof(TargetType), typeof(Type), typeof(SwitchPresenter), new PropertyMetadata(null)); And the type/model was from a UWP class library (different assembly) with no decorations: public class XamlBindingInfo : INotifyPropertyChanged See this post from Jul 29th 2020 where it appears broken at that point: https://stackoverflow.com/questions/47366041/equivalent-of-xtype-in-uwp @Arlodotexe did you file an issue elsewhere we could link to? FYI @MikeHillberg @azchohfi |
@michael-hawker - my guess is in your working scenario, |
@RealTommyKlein would I see that even in a Debug version of I can try rebuilding the version I submitted to the store previously with the current tools, and I can follow-up with you after the long weekend here on Tuesday. |
@michael-hawker you would need to build it as Release to see the expected codegen in
If |
I've opened a task for WinUI 3 so if the compiler encounters something like |
This has been fixed for the upcoming Windows App SDK 1.1 release, closing this issue |
Keeping this open until it's available in a public release |
I've validated that this works fine in OS/XAML:
Steps to reproduce the bug
Latest WinUI3-preview4 (but this is not a regression from preview3, it just never worked in WinUI3)
Works totally fine in OS/XAML and the property is never set in WInUI3.
Expected behavior
Simple C# properties of type System.Type should be populated by setting the property in Xaml.
Version Info
WinUI3 Desktop app with version 3.0.0-preview4.210210.4
NuGet package version:
[Microsoft.WinUI 3.0.0-preview4.210210.4]
Windows app type:
Additional context
The text was updated successfully, but these errors were encountered: