-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3222 from Vijay-Nirmal/SmoothScrollIntoView
SmoothScrollIntoView ListView Extension
- Loading branch information
Showing
11 changed files
with
459 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 6 additions & 29 deletions
35
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsCode.bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,9 @@ | ||
<Page | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" | ||
mc:Ignorable="d"> | ||
<GridView x:Name="MyGridView"/> | ||
|
||
<Page.Resources> | ||
<DataTemplate x:Name="NormalTemplate"> | ||
<TextBlock Text="{Binding Title}" Foreground="Green"/> | ||
</DataTemplate> | ||
using Microsoft.Toolkit.Uwp.UI; | ||
|
||
<DataTemplate x:Name="AlternateTemplate"> | ||
<TextBlock Text="{Binding Title}" Foreground="Red"/> | ||
</DataTemplate> | ||
</Page.Resources> | ||
// Scrolling with index | ||
await MyGridView.SmoothScrollIntoViewWithIndexAsync(index: int, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); | ||
|
||
<Grid> | ||
|
||
<ListView | ||
x:Name="SampleListView" | ||
Margin="12" | ||
ItemTemplate="{StaticResource NormalTemplate}" | ||
IsItemClickEnabled="True" | ||
ui:ListViewExtensions.Command="{Binding SampleCommand}" | ||
ui:ListViewExtensions.AlternateColor="#33AAAAAA" | ||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}" | ||
ui:ListViewExtensions.ItemContainerStretchDirection="Both"> | ||
</ListView> | ||
</Grid> | ||
</Page> | ||
// Scrolling with item | ||
await MyGridView.SmoothScrollIntoViewWithItemAsync(item: object, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int); |
63 changes: 50 additions & 13 deletions
63
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,69 @@ | ||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ListViewExtensionsPage" | ||
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.ListViewExtensionsPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages" | ||
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<local:SampleCommand x:Key="SampleCommand" /> | ||
|
||
<DataTemplate x:Name="NormalTemplate"> | ||
<TextBlock Foreground="Green" | ||
Text="{Binding Title}" /> | ||
<TextBlock Text="{Binding}" Foreground="Green" VerticalAlignment="Center" FontWeight="Bold"></TextBlock> | ||
</DataTemplate> | ||
|
||
<DataTemplate x:Name="AlternateTemplate"> | ||
<TextBlock Foreground="Red" | ||
Text="{Binding Title}" /> | ||
<TextBlock Text="{Binding}" Foreground="Red" VerticalAlignment="Center" FontWeight="Bold"></TextBlock> | ||
</DataTemplate> | ||
</Page.Resources> | ||
|
||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid x:Name="XamlRoot" Grid.Column="0" Margin="12"> | ||
<ListView x:Name="SampleListView" | ||
ui:ListViewExtensions.AlternateColor="#33AAAAAA" | ||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}" | ||
ui:ListViewExtensions.Command="{StaticResource SampleCommand}" | ||
ui:ListViewExtensions.ItemContainerStretchDirection="Both" | ||
IsItemClickEnabled="True" | ||
ItemTemplate="{StaticResource NormalTemplate}" /> | ||
</Grid> | ||
|
||
<ListView x:Name="SampleListView" | ||
Margin="12" | ||
ui:ListViewExtensions.AlternateColor="#33AAAAAA" | ||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}" | ||
ui:ListViewExtensions.Command="{Binding SampleCommand}" | ||
ui:ListViewExtensions.ItemContainerStretchDirection="Both" | ||
IsItemClickEnabled="True" | ||
ItemTemplate="{StaticResource NormalTemplate}" /> | ||
<StackPanel Grid.Column="1" Margin="5,10,10,0" Width="200"> | ||
<TextBlock Text="Smooth Scroll Settings" FontSize="{StaticResource TextStyleLargeFontSize}" Margin="0,0,0,10"/> | ||
<TextBox x:Name="IndexInput" | ||
Header="Index" | ||
InputScope="Number" | ||
Text="100" /> | ||
<ComboBox x:Name="ItemPlacementInput" | ||
Header="Item Placement" | ||
SelectedIndex="0"> | ||
<x:String>Default</x:String> | ||
<x:String>Left</x:String> | ||
<x:String>Top</x:String> | ||
<x:String>Center</x:String> | ||
<x:String>Right</x:String> | ||
<x:String>Bottom</x:String> | ||
</ComboBox> | ||
<CheckBox x:Name="DisableAnimationInput" | ||
Content="Disable Animation" | ||
IsChecked="False" /> | ||
<CheckBox x:Name="ScrollIfVisibileInput" | ||
Content="Scroll If Visible" | ||
IsChecked="True" /> | ||
<TextBox x:Name="AdditionalHorizontalOffsetInput" | ||
Header="Horizontal Offset" | ||
InputScope="Number" | ||
Text="0" /> | ||
<TextBox x:Name="AdditionalVerticalOffsetInput" | ||
Header="Vertical Offset" | ||
InputScope="Number" | ||
Text="0" /> | ||
</StackPanel> | ||
</Grid> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ListViewExtensions/ListViewExtensionsXaml.bind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Page | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="using:Microsoft.Toolkit.Uwp.SampleApp.SamplePages" | ||
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" | ||
mc:Ignorable="d"> | ||
|
||
<Page.Resources> | ||
<local:SampleCommand x:Key="SampleCommand" /> | ||
|
||
<DataTemplate x:Name="NormalTemplate"> | ||
<TextBlock Text="{Binding}" Foreground="Green" VerticalAlignment="Center" FontWeight="Bold"></TextBlock> | ||
</DataTemplate> | ||
|
||
<DataTemplate x:Name="AlternateTemplate"> | ||
<TextBlock Text="{Binding}" Foreground="Red" VerticalAlignment="Center" FontWeight="Bold"></TextBlock> | ||
</DataTemplate> | ||
</Page.Resources> | ||
<ListView | ||
x:Name="SampleListView" | ||
ItemTemplate="{StaticResource NormalTemplate}" | ||
IsItemClickEnabled="True" | ||
ui:ListViewExtensions.Command="{StaticResource SampleCommand}" | ||
ui:ListViewExtensions.AlternateColor="#33AAAAAA" | ||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}" | ||
ui:ListViewExtensions.ItemContainerStretchDirection="Both"> | ||
</ListView> | ||
</Page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.