I'm building a UWP app using C# and having trouble getting multiple listviews to scroll simultaneously.
I have 3 listviews: ListViewA, ListViewB and ListViewC.
If I scroll ListViewA, then both ListViewB and ListViewC should scroll. If I scroll ListView B, then ListViewA and ListViewC will scroll, and the same is true if I scroll ListViewC.
I've done the usual searching and trying examples here on Stackoverflow, along with following links provided by other members. Still not getting the solution to this problem. Hoping someone here might be able to shed some light, or offer some insight on where to look?
I'm using an MVVM approach to populate the listviews and that functions as expected.
It's now just getting all 3 listviews to scroll at once. Let me know if you need any additional info. Thanks.
public class TestModel
{
int ID {get; set;}
string ColumnA {get; set;}
string ColumnB {get; set;}
string ColumnC {get; set;}
}
public class MainPage : Page
{
public TestModelViewModel ViewModel { get; set; }
public MainPage()
{
this.InitializeComponent();
ViewModel = new TestModelViewModel("Filename=TestModelDB.db");
}
}
<ListView x:Name="ListViewA" ItemsSource="{x:Bind ViewModel.CollectionOfTestModelData, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewModels:TestModelViewModel" >
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Bind ColumnA, Mode=OneWay}"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="ListViewB" ItemsSource="{x:Bind ViewModel.CollectionOfTestModelData, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewModels:TestModelViewModel" >
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Bind ColumnB, Mode=OneWay}"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="ListViewC" ItemsSource="{x:Bind ViewModel.CollectionOfTestModelData, Mode=OneWay}">
<ListView.ItemTemplate>
<DataTemplate x:DataType="viewModels:TestModelViewModel" >
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{x:Bind ColumnC, Mode=OneWay}"/>
</Grid>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>