This is a migrated thread and some comments may be shown as answers.

How do I add images to GroupHeader

1 Answer 51 Views
JumpList
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jimmy Engström
Top achievements
Rank 1
Jimmy Engström asked on 03 Jan 2012, 03:03 AM
Hi
I have a jumplist with groups, and I would like to have an ímage and a string in the groupheader.
What I did was I created a class:
public class ChannelGroup : IComparable<ChannelGroup>
{
    public string ChannelName { get; set; }
    public string ChannelUrl { get; set; }
 
 
 
    public int CompareTo(ChannelGroup other)
    {
        return other.ChannelName.CompareTo(ChannelName);
    }
}
and then used the following code to set the GroupDescriptor
var nowdg = new GenericGroupDescriptor<ListingItem, ChannelGroup>();
           nowdg.KeySelector = (ListingItem t) =>
           {
               return new ChannelGroup() {ChannelName=t.ChannelName,ChannelUrl=t.ChannelImageUrl };
           };
           nowdg.SortMode = ListSortMode.None;
           NowJumpList.GroupDescriptors.Add(nowdg);

It seems like the comparer doesn't work as exected I don't get any grouping at all every item in the list gets a
new group (I have checked ant the comparer that is implemented does return zero as it should (when matching).

Am I doing this all wrong?
Is there a better way to do it?
Cheers
/Jimmy

1 Answer, 1 is accepted

Sort by
0
Accepted
Deyan
Telerik team
answered on 04 Jan 2012, 09:40 AM
Hello,

Thanks for contacting us and for the provided code snippets.

In order to achieve the desired behavior, you will have to override the Equals and GetHashCode methods in the ChannelGroup class. You do notr need to implement the IComparable interface in this case.

I have prepared a demo project that demonstrates similar scenario, also including code for displaying image within the Group Header.

I hope this helps.

Greetings,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
JumpList
Asked by
Jimmy Engström
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or