Added Scroll indicator
This commit is contained in:
Родитель
525bc25913
Коммит
b1033fb211
|
@ -35,14 +35,16 @@
|
|||
</Grid>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="5,10,10,0" Width="200">
|
||||
<TextBlock Text="Smooth Scroll Settings" FontSize="{StaticResource TextStyleLargeFontSize}" Margin="0,0,0,10"/>
|
||||
<TextBlock Text="Smooth Scroll Settings" FontSize="{StaticResource TextStyleLargeFontSize}"/>
|
||||
<TextBox x:Name="IndexInput"
|
||||
Header="Index"
|
||||
InputScope="Number"
|
||||
Text="100" />
|
||||
Text="100"
|
||||
Margin="0,10,0,0" />
|
||||
<ComboBox x:Name="ItemPlacementInput"
|
||||
Header="Item Placement"
|
||||
SelectedIndex="0">
|
||||
SelectedIndex="0"
|
||||
Margin="0,10,0,0" >
|
||||
<x:String>Default</x:String>
|
||||
<x:String>Left</x:String>
|
||||
<x:String>Top</x:String>
|
||||
|
@ -52,18 +54,25 @@
|
|||
</ComboBox>
|
||||
<CheckBox x:Name="DisableAnimationInput"
|
||||
Content="Disable Animation"
|
||||
IsChecked="False" />
|
||||
IsChecked="False"
|
||||
Margin="0,10,0,0" />
|
||||
<CheckBox x:Name="ScrollIfVisibileInput"
|
||||
Content="Scroll If Visible"
|
||||
IsChecked="True" />
|
||||
<TextBox x:Name="AdditionalHorizontalOffsetInput"
|
||||
Header="Horizontal Offset"
|
||||
InputScope="Number"
|
||||
Text="0" />
|
||||
Text="0"
|
||||
Margin="0,10,0,0" />
|
||||
<TextBox x:Name="AdditionalVerticalOffsetInput"
|
||||
Header="Vertical Offset"
|
||||
InputScope="Number"
|
||||
Text="0" />
|
||||
Text="0"
|
||||
Margin="0,10,0,0" />
|
||||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
|
||||
<Ellipse x:Name="ScrollIndicator" Fill="Red" Width="15" Height="15"/>
|
||||
<TextBlock x:Name="ScrollIndicatorTest" Text="Scroll not started" Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -6,9 +6,11 @@ using System;
|
|||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.Toolkit.Uwp.UI;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
||||
{
|
||||
|
@ -55,7 +57,9 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
var scrollIfVisibile = ScrollIfVisibileInput.IsChecked ?? true;
|
||||
var additionalHorizontalOffset = int.TryParse(AdditionalHorizontalOffsetInput.Text, out var ho) ? ho : 0;
|
||||
var additionalVerticalOffset = int.TryParse(AdditionalVerticalOffsetInput.Text, out var vo) ? vo : 0;
|
||||
UpdateScrollIndicator(true);
|
||||
await sampleListView.SmoothScrollIntoViewWithIndexAsync(index, itemPlacement, disableAnimation, scrollIfVisibile, additionalHorizontalOffset, additionalVerticalOffset);
|
||||
UpdateScrollIndicator(false);
|
||||
});
|
||||
|
||||
if (sampleListView != null)
|
||||
|
@ -64,6 +68,20 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateScrollIndicator(bool isScrolling)
|
||||
{
|
||||
if (isScrolling)
|
||||
{
|
||||
ScrollIndicatorTest.Text = "Scroll started";
|
||||
ScrollIndicator.Fill = new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScrollIndicator.Fill = new SolidColorBrush(Colors.Red);
|
||||
ScrollIndicatorTest.Text = "Scroll completed";
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<string> GetOddEvenSource(int count)
|
||||
{
|
||||
var oddEvenSource = new ObservableCollection<string>();
|
||||
|
|
|
@ -201,6 +201,12 @@ namespace Microsoft.Toolkit.Uwp.UI
|
|||
/// <param name="disableAnimation">if set to <c>true</c> disable animation.</param>
|
||||
private static async Task ChangeViewAsync(this ScrollViewer scrollViewer, double? horizontalOffset, double? verticalOffset, float? zoomFactor, bool disableAnimation)
|
||||
{
|
||||
// MUST check this an return immediately, otherwise this async task will never completes because ViewChanged event won't triggered
|
||||
if (horizontalOffset == scrollViewer.HorizontalOffset && verticalOffset == scrollViewer.VerticalOffset)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
void ViewChanged(object _, ScrollViewerViewChangedEventArgs e)
|
||||
|
|
Загрузка…
Ссылка в новой задаче