【问题标题】:Windows Metro: Is XPath binding supported in XAMLWindows Metro:XAML 中是否支持 XPath 绑定
【发布时间】:2012-09-24 14:14:17
【问题描述】:

Windows Metro 编程新手。

我想将 XML 数据与 UI XAML 相关联。

在 Windows 8 应用程序中可以通过定义 dataProvider:

XmlDataProvider x:Key="InventoryData" XPath="Inventory/Books"

绑定到 UI 为:

  <Binding Source="{StaticResource InventoryData}"
           XPath="*[@Stock='out'] | *[@Number>=8 or @Number=3]"/>

尝试使用 VS2012 RC 为 Windows Metro C# 应用程序做同样的事情。

XAML 中的错误:找不到类型“XmlDataProvider”。

有人可以帮忙吗。

【问题讨论】:

    标签: xaml xpath windows-8 microsoft-metro


    【解决方案1】:

    XPath 属性是Binding class in WPF xaml 的一部分。 metro Binding class 没有这个属性。有一个示例说明如何扩展此 here 的 WPF 实现,您可能可以将其移植到 Metro。

    【讨论】:

    • 你说得对,Metro Binding 类不支持 XPath 属性。
    • 请您详细说明移植解决方案。据我了解,在没有 XMLDataProvider 的情况下,需要实现自定义类来封装 XMLdata 并实现:IValueConverter 接口。正确的?在这种情况下,UIBinding 是什么?或转换器就足够了?
      感谢所有帮助,努力在 Metro 开发中找到自己的立足点。
    • 我的建议是将所有文档功能放在一个属性中,然后绑定到该属性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 2017-12-19
    • 1970-01-01
    相关资源
    最近更新 更多