How do I add images to GroupHeader

2 posts, 1 answers
  1. Jimmy Engström
    Jimmy Engström avatar
    1 posts
    Member since:
    Jan 2010

    Posted 02 Jan 2012 Link to this post

    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
  2. Answer
    Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 04 Jan 2012 Link to this post

    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 >>

  3. DevCraft banner
Back to Top