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

SelectedTemplate perfect fit

4 Answers 76 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fredrik
Top achievements
Rank 1
Fredrik asked on 21 Jun 2011, 01:14 PM
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

4 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 23 Jun 2011, 07:24 AM
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>>
0
Fredrik
Top achievements
Rank 1
answered on 23 Jun 2011, 07:58 PM
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
0
Accepted
Deyan
Telerik team
answered on 27 Jun 2011, 12:13 PM
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>>
0
Fredrik
Top achievements
Rank 1
answered on 27 Jun 2011, 12:34 PM
Hi !!

Support ticket created.

Regards

Fredrik
Tags
DataBoundListBox
Asked by
Fredrik
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Fredrik
Top achievements
Rank 1
Share this question
or