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

BringIntoView problem

4 Answers 110 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.
Thomas
Top achievements
Rank 1
Thomas asked on 19 Mar 2012, 08:08 PM
Hi,

I've been using your DataBoundListBox, which has provided good performance for my app. However, I recently tried to use the BringIntoView() method - the method itself works fine, but if you select an item that is at the end, or towards the end of a collection, the view will be "stuck" on the bottom of the listbox, and not be able to scroll up to the previous items.

Unfortunately, if I can't get this to work, I'll have to switch back to using the regular ListBox, is there any work around or fix that you can provide for this?

Thanks,
Tommy

4 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 20 Mar 2012, 02:05 PM
Hi Thomas,

Thank you for contacting us. Unfortunately I was not able to reproduce the issue. Could you please take a look at the attached project and let me know if I am missing anything. I'd be glad to further assist you. 

Greetings,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Thomas
Top achievements
Rank 1
answered on 20 Mar 2012, 04:40 PM
Hi Kiril,

Thanks for replying - I have edited the solution and was able to get the problem to occur, I can't attach it here, but I can send it if you would like.

The parts I changed were:
  • Added a header
  • Changed the listbox options to
    IsAsyncBalanceEnabled="True" AsyncBalanceMode="FillViewportFirst"
    
  • Changed to have the collection load on button click, and immediately bring into view (this simulates my use case, where a collection of comments is loaded from a web request, and then a specific comment is brought into view on load)

Xaml changes:

<telerikPrimitives:RadDataBoundListBox Grid.ColumnSpan="2" IsAsyncBalanceEnabled="True" AsyncBalanceMode="FillViewportFirst" x:Name="dataBoundListBox1" ItemsSource="{Binding DataItems}">
                <telerikPrimitives:RadDataBoundListBox.ListHeaderContent>
                    <StackPanel>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock Style="{StaticResource HeaderStyle}">Test Header</TextBlock>
                        <TextBlock>Test Header</TextBlock>
 
                        <TextBlock>Test Header</TextBlock>
 
                        <TextBlock>Test Header</TextBlock>
 
                        <TextBlock>Test Header</TextBlock>
 
                        <TextBlock>Test Header</TextBlock>
 
                        <TextBlock>Test Header</TextBlock>
                     
                    </StackPanel>
                         
                         
                </telerikPrimitives:RadDataBoundListBox.ListHeaderContent>
                <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <TextBlock Text="{Binding Title}" FontSize="48"/>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
            </telerikPrimitives:RadDataBoundListBox>

Code changes

private MainViewModel mainViewModel = new MainViewModel(300);
 
public MainPage()
{
    InitializeComponent();
 
}
 
 
private void BringIntoView_Click(object sender, RoutedEventArgs e)
{
    this.DataContext = this.mainViewModel;
    this.dataBoundListBox1.BringIntoView(this.mainViewModel.DataItems[this.mainViewModel.DataItems.Count - 1]);
}


Hope this helps track down the issue!

Thanks,
Tommy

0
Accepted
Kiril Stanoev
Telerik team
answered on 21 Mar 2012, 10:59 AM
Hi Thomas,

I can confirm that your changes reproduce the issue. We will do our best to provide a fix for it with any of the upcoming internal builds after our Q1 2012 SP1 release (scheduled for this week). Meanwhile, you can implement the following workaround:

private void BringIntoView_Click(object sender, RoutedEventArgs e)
{
    this.DataContext = this.mainViewModel;
 
    this.Dispatcher.BeginInvoke(() =>
    {
        this.dataBoundListBox1.BringIntoView(this.mainViewModel.DataItems[this.mainViewModel.DataItems.Count - 1]);
    });
}

Give it a try and let me know if it works for you. I'd be glad to further assist you. 

Regards,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Thomas
Top achievements
Rank 1
answered on 23 Mar 2012, 06:06 PM
This did work, thank you for the reply! Looking forward to the fix in the next revision :)
Tags
DataBoundListBox
Asked by
Thomas
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or