When using x:Bind in a UWP XAML application consider the following:
interface IBaseInterface
{
string A { get; set; }
}
interface ISubInterface : IBaseInterface
{
string B { get; set; }
}
class ImplementationClass : ISubInterface
{
public string A { get; set; }
public string B { get; set; }
}
In the Page class we have the following:
public partial class MainPage : Page
{
public ISubInterface TheObject = new ImplementationClass { A = "1", B = "2" };
//All the rest goes here
}
In the MainPage XAML we have the following snippet:
<TextBlock Text={x:Bind Path=TheObject.A}></TextBlock>
Which causes the following compiler error: XamlCompiler error WMC1110: Invalid binding path 'A' : Property 'A' can't be found on type 'ISubInterface'
The following does work however:
<TextBlock Text={x:Bind Path=TheObject.B}></TextBlock>
Does anybody know if it is a known limitation of the UWP XAML platform that inherited interface-properties are not recognized by the compiler? Or should this be considered a bug? Are there any known workarounds?
Help is greatly appreciated. Thanks in advance!
TheObject
asIBaseInterface
rather thanISubInterface
and see if the Compiler then acceptsTheObject.A
? – Folie