2017-07-21 40 views
1

我正在使用Telerik的PostSharp和RadGridView。某些列使用DataTypeConverter來定製數據,我正在使用它來從AdvisableDictionary<Tkey, TValue>類型的名爲Name的屬性中加載值。PostSharp get_Property錯誤

網格有過濾器按鈕,單擊時會顯示一個類似Excel的過濾選項的彈出窗口。

但是,當我點擊這個按鈕,我得到一個錯誤說Failed to compare two elements in the array.這隻發生在這種類型的數據的列。我對PostSharp沒有多少經驗,但我認爲這是由PostSharp生成的。

下面是輸出窗口的最後幾行從PostSharp,它會拋出異常之前:

The thread 0x3964 has exited with code 0 (0x0). 

The thread 0x364 has exited with code 0 (0x0). 

Step into: Stepping over non-user code 'TranslatableObject.get_Name' 

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding1.GetValue' 

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding1.get_LocationInfo' 

Step into: Stepping over non-user code 'TranslatableObject.<Name>c__Binding.GetValue' 

我能做些什麼來解決這個問題?

+0

能否請您粘貼在這裏異常的堆棧跟蹤和完整的消息?如果您分享了一個可以再現此行爲的最小示例,那麼也可以幫助找出原因。 –

+0

謝謝! [Here](http://www.telerik.com/account/ClientsFiles/2e7a5d04-c0cc-4c2f-a835-8531ead667c4_ExcelLikeFiltering.zip?accesskey=76010F0054C6AF950F4458F5A0E88AD6643EF13E&expires=636369830483897924)是一個示例項目。我在下面的答案中找到了一個解決方案。 – Tim

回答

-1

我想出了一個解決方案。 AdvisableDctionary不實現用於排序項目列表的IComparable。我創建了一個繼承AdvisableDictionary並實現IComparable的類,並在FilterPopup的FilterConfirmed事件中更正了過濾器描述符的值。

0

您可以創建一個類來繼承AdvisableDictionary並實現IComparable。

public class AdvisableDictionary: IComparable 
{ 
    //here add the code from your heart 
} 

HERE 1

HERE 2

因此,它在FilterPopup的FilterConfirmed事件簡單,你需要正確的過濾器描述符的值。

就是這樣。

以下是樣本prj。請看一下。玩得開心享受C#編程。

,它是我的解決方案,需要嘗試,是一個老闆,要努力,要快樂:)