question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting property of type System.Type in XAML doesn't set the property

See original GitHub issue

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)

    public class GraphPresenter : ContentPresenter
    {
        public GraphPresenter()
        {
            Loaded += GraphPresenter_Loaded;
        }

        public Type ResponseType { get; set; }

        private void GraphPresenter_Loaded(object sender, RoutedEventArgs e)
        {
            Debug.WriteLine(ResponseType); // This should have the type, but its null
        }
    }
    public class AnyClass
    {
    }
<local:GraphPresenter ResponseType="local:AnyClass"/>

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:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
RealTommyKleincommented, Feb 17, 2021

I’ve opened a task for WinUI 3 so if the compiler encounters something like TypeProperty="local:Foo", it will generate type information for Foo so this scenario will work without a dummy class/adding the Bindable attribute.

0reactions
MikeHillbergcommented, Dec 13, 2021

Keeping this open until it’s available in a public release

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Using System.Type in XAML
Use the x:Type Markup Extension: <MyUserControl xmlns:myns="clr-namespace:My.NameSpace" x:Name="TheControl" TheType="{x:Type ...
Read more >
x:Type Markup Extension - XAML
The x:Type markup extension supplies a from-string conversion behavior for properties that take the type Type. The input is a XAML type.
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 >
Avoiding binding errors when part of the path is null - Forums
Anyway, in this particular scenario I see that Noesis considers a binding error when a property of the binding path returns null and...
Read more >
Code annotation attributes | ReSharper Documentation
Use this annotation to specify a type that contains static or const fields with values for the annotated property/field/parameter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found