I am populating my Accordion with items from my database. I have also wrapped my Accordion in a ScrollViewer:
<ScrollViewer Name="LayoutScrollViewer">
<toolkit:Accordion Name="ItemsAccordion" ItemTemplate="{StaticResource AccordionHeaderTemplate}" ContentTemplate="{StaticResource AccordionContentTemplate}"></toolkit:Accordion>
</ScrollViewer>
However, I cannot find a way to initially show the VerticalOffset of the ScrollViewer to 0. It keeps on scrolling to the bottom whenever my database content is finished loading. I have tried in the codebehind:
void CatalogItem_Loaded(object sender, RoutedEventArgs e)
{
WebServiceClient client = new WebServiceClient();
client.GetCatalogItemsAsync(countID);
client.GetCatalogItemsCompleted += new EventHandler<GetCatalogItemsCompletedEventArgs>(client_GetCatalogItemsCompleted);
}
void client_GetCatalogItemsCompleted(object sender, GetCatalogItemsCompletedEventArgs e)
{
ItemsAccordion.ItemsSource = e.Result;
UpdateScrollViewer();
}
private void UpdateScrollViewer()
{
LayoutScrollViewer.ScrollToVerticalOffset(0);
}
This doesn't work, though. I have also tried, in UpdateScrollViewer() to do:
LayoutScrollViewer.IsHitTestVisible = false;
LayoutScrollViewer.IsHitTestVisible = true;
which doesn't work either. If I leave it as IsHitTestVisible= false, then it works as I would like; but I also want user interaction with the Accordion, so this isn't a permanent solution.