XAML 中的 XPath 绑定错误 [英] Error in XPath binding in XAML

查看:22
本文介绍了XAML 中的 XPath 绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XAML 中有一个绑定:

I have a binding in XAML:

{Binding XPath=List/Item[@Status='OK']}

Visual Studio 告诉我它期待 ' 和 } 但是当我查看其他地方的文档时,似乎这条线看起来不错.它不会编译并给我一个错误,指出成员 List/Item[@Status='OK'] 不可访问.

Visual Studio tells me it's expecting ' and } but when I look at documentation elsewhere, it seems this line looks fine. It won't compile and gives me an error saying that the member List/Item[@Status='OK'] is not accessible.

我做错了什么?

推荐答案

要解决此问题,请尝试使用引号转义整个 XPath 表达式,并使用 &quot 在 XPath 内转义引号; :

To fix the problem, try to escape the entire XPath expression with quotes, and escape quotes inside XPath using " :

{Binding XPath='List/Item[@Status="OK"]'}

或者其他选项,使用反斜杠转义等号和单引号:

Or another option, escape equals sign and single quotes using backslash :

{Binding XPath=List/Item[@Status\=\'OK\']}

参考资料:

这篇关于XAML 中的 XPath 绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆