您将如何制作一个列表<>可比?

发布于 2024-09-02 06:11:16 字数 1456 浏览 1 评论 0 原文

我正在使用 Telerik GridView,并且在尝试对列进行排序时遇到问题它由 List<> 组成。在论坛条目中, Telerik 团队表示,网格可以对 IComparable 进行排序并对 IEquatable<> 进行分组/过滤。无论 Silverlight 版本如何。在下面的 xaml 中,您将看到网格中的四列。 SVO 专栏是我遇到问题的专栏。 SVO 绑定到列表 (ServiceOrder_DataViewModel)。由于列表未实现 IComparable 或 IEquatable,因此我无法对该列进行排序或分组/过滤。所以,我的问题是:如何创建一个实现 IComparable 和 IEquatable 的新 List 对象?我们确实有逻辑能够实现 IComparable 和 IEquatable,我只是不确定如何实现它。任何帮助将不胜感激!

<d:MVVMRadGridView.Columns>
    <telerikGridView:GridViewDataColumn Header="Case Id" UniqueName="Id" CellTemplate="{StaticResource CaseIDLinkCellTemplate}" DataMemberBinding="{Binding Id}" DisplayIndex="0" IsVisible="True" />
    <telerikGridView:GridViewDataColumn Header="SVOs" UniqueName="SVOs" CellTemplate="{StaticResource CaseServiceOrdersLinksCellTemplate}" DisplayIndex="1" IsVisible="True" TextWrapping="Wrap" />
    <telerikGridView:GridViewDataColumn Header="Type" UniqueName="Type" DataMemberBinding="{Binding Type}" DisplayIndex="2" IsVisible="True" TextWrapping="Wrap" />
    <telerikGridView:GridViewDataColumn Header="Status" UniqueName="Status" DataMemberBinding="{Binding Status}" DisplayIndex="3" IsVisible="True" />
</d:MVVMRadGridView.Columns>

I am using a Telerik GridView, and having an issue trying to sort a column that is made of of a List<>. In this forum entry, the Telerik team states that the grid can sort IComparable and group/filter IEquatable<> no matter of the Silverlight version. In the xaml below, you will see the four columns that I have in my grid. The SVOs column is the one that I'm having the issue with. SVOs is bound to a List(ServiceOrder_DataViewModel). Since a List does not implement IComparable or IEquatable, I cannot sort or group/filter this column. So, my question is: how do I create a new List object that implements IComparable and IEquatable? We do have logic to be able to implement the IComparable and IEquatable, I'm just not sure how to implement it. Any help would be greatly appreciated!

<d:MVVMRadGridView.Columns>
    <telerikGridView:GridViewDataColumn Header="Case Id" UniqueName="Id" CellTemplate="{StaticResource CaseIDLinkCellTemplate}" DataMemberBinding="{Binding Id}" DisplayIndex="0" IsVisible="True" />
    <telerikGridView:GridViewDataColumn Header="SVOs" UniqueName="SVOs" CellTemplate="{StaticResource CaseServiceOrdersLinksCellTemplate}" DisplayIndex="1" IsVisible="True" TextWrapping="Wrap" />
    <telerikGridView:GridViewDataColumn Header="Type" UniqueName="Type" DataMemberBinding="{Binding Type}" DisplayIndex="2" IsVisible="True" TextWrapping="Wrap" />
    <telerikGridView:GridViewDataColumn Header="Status" UniqueName="Status" DataMemberBinding="{Binding Status}" DisplayIndex="3" IsVisible="True" />
</d:MVVMRadGridView.Columns>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

臻嫒无言 2024-09-09 06:11:16

您可以扩展列表类并实现 IComparable 和 IEquatable 方法吗?

public class ComparableList<T> : List<T>, 
   IComparable<List<T>>, IEquatable<List<T>> 
{
    // Implement IComparable and IEquatable using your rules.
}

Can you just extend the list class and implement the IComparable and IEquatable methods?

public class ComparableList<T> : List<T>, 
   IComparable<List<T>>, IEquatable<List<T>> 
{
    // Implement IComparable and IEquatable using your rules.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文