XAML错误(C#,WPF)中的XPATH相等表达式值

use*_*249 2 wpf xaml xpath

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

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

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

<ComboBox ItemTemplate="{StaticResource rolelistTemplate}" ItemsSource="{Binding XPath=/EssenceList/Essence[@Type="Role"]}" IsSynchronizedWithCurrentItem="True"/>
Run Code Online (Sandbox Code Playgroud)

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

 <ComboBox ItemTemplate="{StaticResource rolelistTemplate}"  ItemsSource="{Binding XPath=/EssenceList/Essence[@Type='Role']}" IsSynchronizedWithCurrentItem="True" /> 
Run Code Online (Sandbox Code Playgroud)

Jul*_*ain 6

首先,将整个XPath包含在内,'以便XAML解析器不会尝试将其解释@Type=为语法错误.然后,使用标准XML实体" 代表双引号:

{Binding XPath='/EssenceList/Essence[@Type=&quot;Role&quot;]'}
Run Code Online (Sandbox Code Playgroud)