SelectedTemplate perfect fit

5 posts, 1 answers
  1. Fredrik
    Fredrik avatar
    54 posts
    Member since:
    Sep 2010

    Posted 21 Jun 2011 Link to this post

    Hi !!!

    My problem is when I click a row and change the template to my "selected" template, that template is heigher than the normal one.
    I would like the ListBox to scroll the items so the selected row is in focus (the top visible row if its a must to show the content).
    As now if the clicked row is the last row that is visible then its content is partially visible but not all because its the last row.

    Can I do this today or do I have to calculate this myself ?

    Regards

    Fredrik
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 23 Jun 2011 Link to this post

    Hi Fredrik,

    Thanks for writing.

    The only way to focus an item into the viewport is to call the BringIntoView method. This method will make the item appear at the top edge of the viewport.

    When the size of an item changes (for instance when you change the template of the item) RadDataBoundListBox simply offsets the following visual containers so that enough space is accomodated for the item that has updated bounds. There is no functionality that will offset the item itself so that it perfectly fits in the bounds of the viewport.

    I hope this helps.

    Do not hesitate to get back to us in case you have further questions.

    Best wishes,
    Deyan
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. Fredrik
    Fredrik avatar
    54 posts
    Member since:
    Sep 2010

    Posted 23 Jun 2011 Link to this post

    Hi Deyan !!!

    If I set the contenttemplate to anything but the normal one and then call the BringToFront, my "selected" template is not showing.
    The item is reordered to the top item but I can´t get it to show my selected template after bringtofront.
    I have tryied to apply the contenttemplate again after bringtofront nut no luck.
    I´m having it like this (I´m using MVVM and item is set with the "selected" template before calling EnsureVisibleItem).

      private void EnsureVisibleItem(object item)
            {
                RadDataBoundListBox rad1 = FindName<RadDataBoundListBox>("ToDoAdvancedList", this);
                rad1.BringIntoView(item);
                RadDataBoundListBoxItem visualContainer = rad1.GetContainerForItem(item) as RadDataBoundListBoxItem;
                if (visualContainer != null)
                {
                    visualContainer.ContentTemplate = visualContainer.ContentTemplate;
                }
            }

    Regards

    Fredrik
  5. Answer
    Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 27 Jun 2011 Link to this post

    Hello Fredrik,

    Since I am not quite sure that I correctly understand the scenario. In order to be able to provide you with further assistance, I would like to kindly ask you to prepare a sample project that implements the scenario in question and send it to me so that I can directly take a look and see how I can help.

    Please note that in order to be able to attach your project you will need to open a new support ticket.

    Thanks for your understanding and for the time taken.

    All the best,
    Deyan
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  6. Fredrik
    Fredrik avatar
    54 posts
    Member since:
    Sep 2010

    Posted 27 Jun 2011 Link to this post

    Hi !!

    Support ticket created.

    Regards

    Fredrik
Back to Top
DevCraft banner