0

I have problem with ScrollIntoView...

Last time i used this method and was all OK. But now I have a problem and I don't know why.

I think that i looked at 90% of the Internet about this topic and I have found nothing about it..

Here's my XAML:

<Grid Grid.Row="1" >
    <ListView 
        x:Name="NameOfList" 
        HorizontalAlignment="Stretch" 
        IsZoomedInView="False"
        ItemsSource="{Binding someSource}"
        ItemTemplate="{StaticResource someTemplate}"
        IsItemClickEnabled="True"
        someNamespace:ItemClickedToCommand.Command="{Binding someCommand}"
        SelectedItem="{Binding someSelecteditem, Mode=TwoWay}"
        SelectedIndex="{Binding someselectedindex, Mode=TwoWay}"
        ItemContainerStyle="{StaticResource someContainerStyle}"
        >
    </ListView>
</Grid>

And here's my code-behind:

var page = GetPage();
var someGrid = page.FindName("SomeGridUserControlGrid") as Grid;
var someUserControl = someGrid.FindName("someUserControl") as SomeUserControl;

ListView listViewSome = someUserControl.FindName("SomeListView") as ListView;

// listViewSome is not null, this object has correct value
//but code below doesn’t work…
listViewSome.SelectedItem = someSelecteditem;
listViewSome.ScrollIntoView(listViewSome.SelectedItem);
J. Soe
  • 1
  • Can add the exact error you are getting? – Slizzered May 13 '16 at 13:02
  • "I think that i looked at 90% of the ethernet about this topic..." <-- there's your problem, right there. You're looking in the wrong place! But, seriously could you add more detail about the error you're getting? – Geoff James May 13 '16 at 13:04
  • poorly I expressed, i havent any error, only It doesn't work as it should. – J. Soe May 13 '16 at 13:05
  • Reading between the lines; I have had this problem with WinRT, also. `ScrollIntoView()` isn't working - is the long and short of it. Could you clarify, are you trying to scroll to the top of the `ListView`, an item in the list or other? – Geoff James May 13 '16 at 13:08
  • Scratch that, I've tidied your code up in an edit (was very hard to read before) - I realise that you're trying to scroll to a particular item in the list, right? – Geoff James May 13 '16 at 13:09
  • Possible duplicate of [Let ListView scroll to selected item](http://stackoverflow.com/questions/12108464/let-listview-scroll-to-selected-item) – Geoff James May 13 '16 at 13:10
  • for example: i have 30 elements in listView, i see on the screen only 10, now i want add next element to the list, element is inserted properly, and now i want scroll to this element but it dont work, i did that this element is selected(visually highlighted and programmatically) but i still see first 10 elements at the top of the list, but i want see new(last element of the list) element on the screen by scrollIntoView – J. Soe May 13 '16 at 13:16
  • "I realise that you're trying to scroll to a particular item in the list, right?" exactly – J. Soe May 13 '16 at 13:24

0 Answers0