ListView Scrolling with MVVM
-
Hi , I need to acheive List View Scrolling with MVVM. As iam new to MVVM Can u please let me know how it can be acheived . Can anyone please provide a sample for the same if possible. Thanks Krish
-
Hi , I need to acheive List View Scrolling with MVVM. As iam new to MVVM Can u please let me know how it can be acheived . Can anyone please provide a sample for the same if possible. Thanks Krish
Listview scrolling in general has nothing to do with MVVM and is an inherent property of the control. Could you please give more details so we can understand your question better?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick Visit the Hindi forum here.
-
Hi , I need to acheive List View Scrolling with MVVM. As iam new to MVVM Can u please let me know how it can be acheived . Can anyone please provide a sample for the same if possible. Thanks Krish
I need to scroll the listview on a button click. Iam following MVVM pattern. I tried the following but it is not working.
<local:SortableListView x:Name="headLinesGridView" IsSynchronizedWithCurrentItem="True" Style="{DynamicResource ListViewStyle}" ScrollViewer.VerticalScrollBarVisibility="Hidden" ItemsSource="{Binding Source={StaticResource TestDataSource}}" ItemContainerStyle="{StaticResource headLinesGridViewStyle}" ColumnHeaderSortedAscendingTemplate="HeaderTemplateArrowUp" ColumnHeaderSortedDescendingTemplate="HeaderTemplateArrowDown" ColumnHeaderNotSortedTemplate="HeaderTemplateTransparent"> <ListView.View> <GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderStyle}" ColumnHeaderTemplate="{StaticResource HeaderTemplateTransparent}"> <local:SortableGridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" SortPropertyName="ID" Width="50" /> <local:SortableGridViewColumn Header="First Name" DisplayMemberBinding="{Binding FirstName}" SortPropertyName="FirstName" IsDefaultSortColumn="True"/> <local:SortableGridViewColumn Header="Last Name" DisplayMemberBinding="{Binding LastName}" SortPropertyName="LastName" /> <local:SortableGridViewColumn Header="Date of Birth" DisplayMemberBinding="{Binding DateOfBirth}" SortPropertyName="DateOfBirth" /> <local:SortableGridViewColumn Header="QueueStatus" SortPropertyName="QueueStatus" IsDefaultSortColumn="True" CellTemplate="{StaticResource IconCellTemplate}"/> </GridView> </ListView.View> <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical"></WrapPanel> </ItemsPanelTemplate> </ListView.ItemsPanel> </local:SortableListView> <Button Grid.Row="1" Command="ScrollBar.LineDownCommand" CommandTarget="{Binding ElementName = Test}">Scroll Down</Button>
-
I need to scroll the listview on a button click. Iam following MVVM pattern. I tried the following but it is not working.
<local:SortableListView x:Name="headLinesGridView" IsSynchronizedWithCurrentItem="True" Style="{DynamicResource ListViewStyle}" ScrollViewer.VerticalScrollBarVisibility="Hidden" ItemsSource="{Binding Source={StaticResource TestDataSource}}" ItemContainerStyle="{StaticResource headLinesGridViewStyle}" ColumnHeaderSortedAscendingTemplate="HeaderTemplateArrowUp" ColumnHeaderSortedDescendingTemplate="HeaderTemplateArrowDown" ColumnHeaderNotSortedTemplate="HeaderTemplateTransparent"> <ListView.View> <GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderStyle}" ColumnHeaderTemplate="{StaticResource HeaderTemplateTransparent}"> <local:SortableGridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" SortPropertyName="ID" Width="50" /> <local:SortableGridViewColumn Header="First Name" DisplayMemberBinding="{Binding FirstName}" SortPropertyName="FirstName" IsDefaultSortColumn="True"/> <local:SortableGridViewColumn Header="Last Name" DisplayMemberBinding="{Binding LastName}" SortPropertyName="LastName" /> <local:SortableGridViewColumn Header="Date of Birth" DisplayMemberBinding="{Binding DateOfBirth}" SortPropertyName="DateOfBirth" /> <local:SortableGridViewColumn Header="QueueStatus" SortPropertyName="QueueStatus" IsDefaultSortColumn="True" CellTemplate="{StaticResource IconCellTemplate}"/> </GridView> </ListView.View> <ListView.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical"></WrapPanel> </ItemsPanelTemplate> </ListView.ItemsPanel> </local:SortableListView> <Button Grid.Row="1" Command="ScrollBar.LineDownCommand" CommandTarget="{Binding ElementName = Test}">Scroll Down</Button>
This is a common mistake in MVVM, trying to do too much in the VM. As this line down operation has absolutely no bearing on the model, it's perfectly fine to do this in code behind the view; after all, you just want to move the scrollbar on a visual. Go for it.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads
-
This is a common mistake in MVVM, trying to do too much in the VM. As this line down operation has absolutely no bearing on the model, it's perfectly fine to do this in code behind the view; after all, you just want to move the scrollbar on a visual. Go for it.
I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be
Forgive your enemies - it messes with their heads