在 UWP XAML 应用程序中使用 x:Bind 时,请考虑以下事项:
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; }
}
在 Page 类中,我们有以下内容:
public partial class MainPage : Page
{
public ISubInterface TheObject = new ImplementationClass { A = "1", B = "2" };
//All the rest goes here
}
在 MainPage XAML 中,我们有以下代码段:
<TextBlock Text={x:Bind Path=TheObject.A}></TextBlock>
这会导致以下编译器错误:XamlCompiler error WMC1110: Invalid binding path 'A' : Property 'A' can't be found on type 'ISubInterface'
但是,以下确实有效:
<TextBlock Text={x:Bind Path=TheObject.B}></TextBlock>
有人知道编译器无法识别继承的接口属性是否是 UWP XAML 平台的已知限制?或者这应该被认为是一个错误?是否有任何已知的解决方法?
非常感谢您的帮助。提前致谢!