Currently I have a listbox and expander as listboxitemtemplate. At a time user can select only one item and the expanders will expand if selected. Now i have to add a scrollviewer and during the scroll the expander header should stay sticky to the listbox even when the selected listboxitem is out of current view. In HTML we can achieve this with setting header div with sticky and content as relative.
The sample code to try this is here
<ScrollViewer>
<ListBox Grid.Row="1" DockPanel.Dock="Top">
<Expander Header="head1" Content="content1" IsExpanded="True"/>
<Expander Header="head2" Content="content2"/>
<Expander Header="head3" Content="content3"/>
<Expander Header="head4" Content="content4"/>
</ListBox>
</ScrollViewer>
I have tried ListBox.scrollintoview() but it locks the scroll after selected item. I also tried with dockpanel and docking it to the top. But it didn't produce the result as expected. Kindly help with any suggestions or code.