XAML 错误中的 XPATH 相等表达式值(C#、WPF) [英] XPATH equality expression value in XAML Errors (C#, WPF)

查看:22
本文介绍了XAML 错误中的 XPATH 相等表达式值(C#、WPF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN 说 http://msdn.microsoft.com/en-us/library/ms256086.aspx

degree[@from != "Harvard"] - from 属性不等于Harvard"的所有元素.

degree[@from != "Harvard"] - All elements where the from attribute is not equal to "Harvard".

但是当尝试在我的 xaml 代码中实现它时会导致错误,因为在 XAML 语法中,所有值元素都应该放在引号中,我该如何解决这个问题?

but when trying to implement this in my xaml code it causes an error because in XAML syntax all the value elements should be placed in quotes, how can i workaround this?

<ComboBox ItemTemplate="{StaticResource rolelistTemplate}" ItemsSource="{Binding XPath=/EssenceList/Essence[@Type="Role"]}" IsSynchronizedWithCurrentItem="True"/>

我也试过这个,但它也给了我语法错误

i've also tried this, but it also gives me syntax errors

 <ComboBox ItemTemplate="{StaticResource rolelistTemplate}"  ItemsSource="{Binding XPath=/EssenceList/Essence[@Type='Role']}" IsSynchronizedWithCurrentItem="True" /> 

推荐答案

首先,用 ' 将整个 XPath 括起来,这样 XAML 解析器就不会试图解释 @Type= 作为语法错误.然后,使用标准 XML 实体 &quot;表示双引号:

First, enclose your whole XPath with ' so that the XAML parser does not try to interpret @Type= as a syntax error. Then, use the standard XML entity &quot; to represent a double quote:

{Binding XPath='/EssenceList/Essence[@Type=&quot;Role&quot;]'}

这篇关于XAML 错误中的 XPATH 相等表达式值(C#、WPF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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