当使用X:绑定在UWP XAML应用程序考虑以下几点:UWP XAML X:绑定继承接口不被识别
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 ISubClass TheObject = new ImplementationClass { A = "1", B = "2" };
//All the rest goes here
}
在MainPage XAML中,我们有以下代码片段:
<TextBlock Text={x:Bind Path=TheObject.A}></TextBlock>
这会导致以下编译器错误: XamlCompiler错误WMC1110:无效的绑定路径“A”:房产“A”不能在类型中找到“ISubInterface”
以下但不工作:
<TextBlock Text={x:Bind Path=TheObject.B}></TextBlock>
有谁知道这是否是一个编译器无法识别继承了接口属性的UWP XAML平台的已知限制? 或者这应该被认为是一个错误? 有没有已知的解决方法?
非常感谢帮助。 在此先感谢!
你可以尝试将'TheObject'定义为'IBaseInterface'而不是'ISubInterface'并查看编译器是否接受'TheObject.A'? – dognose