BringIntoView problem

5 posts, 1 answers
  1. Thomas
    Thomas avatar
    6 posts
    Member since:
    Oct 2010

    Posted 19 Mar 2012 Link to this post

    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
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 20 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Thomas
    Thomas avatar
    6 posts
    Member since:
    Oct 2010

    Posted 20 Mar 2012 Link to this post

    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

  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 21 Mar 2012 Link to this post

    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 >>
  6. Thomas
    Thomas avatar
    6 posts
    Member since:
    Oct 2010

    Posted 23 Mar 2012 Link to this post

    This did work, thank you for the reply! Looking forward to the fix in the next revision :)
Back to Top
DevCraft banner