My application uses a TabControl (with items bound to a collection), where each tab has a data grid (whose lines are bound to a collection on the tab model).
When I scroll the view on one of the tabs, that same scroll action is applied to all the other tabs. What I would like is for each tab to track its own scroll value separately, so you don't lose your place when switching between them.
I've reduced this to a minimal program that displays the same behavior:
Xaml:
<Grid>
<TabControl ItemsSource="{Binding Tabs}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<TabControl.ContentTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding Lines}" ></DataGrid>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Grid>
C#:
public MainWindow()
{
InitializeComponent();
DataContext = this;
for (int i = 0; i < 3; i++)
{
var tab = new Tab();
for (int j = 0; j < 100; j++)
tab.Lines.Add(new Line { Value = (i * 100 + j).ToString() });
Tabs.Add(tab);
}
}
public class Tab
{
public ObservableCollection<Line> Lines { get; set; } = new ObservableCollection<Line>();
}
public class Line
{
public string Value { get; set; }
}
Any insight into why it's doing this would be appreciated.