-
Notifications
You must be signed in to change notification settings - Fork 802
Description
Describe the bug
The x:Bind code generation process fails to recognize properties on dynamic type.
Steps to reproduce the bug
Create a class type called PageTag derived from DynamicObject and implementing ICustomPropertyProvider. Create a Page-derived class called PageBase with a DependencyProperty that holds a PageTag and accessed through dynamic type:
public dynamic? PageTag {
get { return (PageTag?)this.GetValue(PageTagProperty); }
set { this.SetValue(PageTagProperty, value); }
}
public static DependencyProperty PageTagProperty { get; } = DependencyProperty.Register(nameof(PageBase.PageTag), typeof(PageTag), typeof(PageBase), new PropertyMetadata(default(PageTag)));
Assign an instance of PageTag to the PageTag property, such that the instance object has a dynamically defined string property called 'Name'. Now try binding to PageTag.Name using Binding and x:Bind, e.g.:
<TextBlock Text="{Binding PageTag.Name, Mode=OneWay, FallbackValue={x:Null}}" />
<TextBlock Text="{x:Bind PageTag.Name, Mode=OneWay, FallbackValue={x:Null}}" />
The use of Binding works (assuming that DataContext is set correctly). The x:Bind fails at compile time with the message "XamlCompiler error WMC1110: Invalid binding path 'PageTag.Name' : Property 'Name' not found on type 'Object'."
Expected behavior
The message shows that x:Bind is mistakenly replacing 'dynamic' with 'object'. The x:Bind should use the dynamic type in this case, not Object type. It should compile and run.
Screenshots
No response
NuGet package version
None
Windows version
No response
Additional context
No response