2010-06-22 23 views
2

MSDN說http://msdn.microsoft.com/en-us/library/ms256086.aspxXPATH表達式平等值(С#,WPF)

度[@from = 「哈佛」!] - 所有元件,其中從屬性是不等於 「哈佛」。

但是當試圖在我的xaml代碼中實現它時,它會導致錯誤,因爲在XAML語法中,所有值元素都應放在引號中,我該如何解決此問題?

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

我也試過,但它也給了我的語法錯誤

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

回答

5

首先,附上您與'整個的XPath,以便XAML分析器不會試圖解釋@Type=爲語法錯誤。然後,使用標準的XML實體&「代表雙引號:

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

太棒了!這樣可行!謝謝! – user362249 2010-06-22 07:32:11