My ScrollViewer is auto scrolling to a middle offset, even when I try to force it back to a 0 offset it still aligns incorrectly
Here is part of the XAML:
<ScrollViewer x:Name="ScrollView" Grid.Row="0" Grid.Column="0" VerticalScrollBarVisibility="Auto">
<TreeView Grid.ColumnSpan="2" Name="LOBSummaryTree"
BorderThickness="0" DataContext="{Binding}">
<TreeView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
<common:VisibilityConverter x:Key="VisibilityConverter"/>
<common:TextStyleConverter x:Key="TextStyleConverter"/>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate DataType="ContentPresenter">
<StackPanel x:Name="StackGroups" Orientation="Horizontal">
<TextBlock Name="txtBox" Tag="{Binding}">
And the attempt from the code behind to force the offset:
var scrollViewer = this.ScrollView;
if (scrollViewer != null)
{
scrollViewer.InvalidateScrollInfo();
scrollViewer.ScrollToHorizontalOffset(0);
UpdateLayout();
}
What am I doing incorrectly, I want the alignment of the horizontal scollbar to be forced to the left on the initial load of the treeview?