Make scrool controls part of the sample
This commit is contained in:
Родитель
8e6ef0af18
Коммит
2ebe4b2fec
|
@ -20,7 +20,12 @@
|
|||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView x:Name="SampleListView"
|
||||
Grid.Column="0"
|
||||
Margin="12"
|
||||
ui:ListViewExtensions.AlternateColor="#33AAAAAA"
|
||||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}"
|
||||
|
@ -28,5 +33,36 @@
|
|||
ui:ListViewExtensions.ItemContainerStretchDirection="Both"
|
||||
IsItemClickEnabled="True"
|
||||
ItemTemplate="{StaticResource NormalTemplate}" />
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="5,0,5,0" Width="200">
|
||||
<TextBox x:Name="IndexInput"
|
||||
Header="Index"
|
||||
InputScope="Number"
|
||||
Text="0" />
|
||||
<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>
|
|
@ -1,4 +1,4 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
|
@ -15,12 +15,12 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
public sealed partial class ListViewExtensionsPage : Page, IXamlRenderListener
|
||||
{
|
||||
private ListView sampleListView;
|
||||
private TextBlock indexInput;
|
||||
private TextBlock itemPlacementInput;
|
||||
private TextBox indexInput;
|
||||
private ComboBox itemPlacementInput;
|
||||
private CheckBox disableAnimationInput;
|
||||
private CheckBox scrollIfVisibileInput;
|
||||
private TextBlock additionalHorizontalOffsetInput;
|
||||
private TextBlock additionalVerticalOffsetInput;
|
||||
private TextBox additionalHorizontalOffsetInput;
|
||||
private TextBox additionalVerticalOffsetInput;
|
||||
|
||||
public ListViewExtensionsPage()
|
||||
{
|
||||
|
@ -31,12 +31,12 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
public void OnXamlRendered(FrameworkElement control)
|
||||
{
|
||||
sampleListView = control.FindChild("SampleListView") as ListView;
|
||||
indexInput = control.FindChild("IndexInput") as TextBlock;
|
||||
itemPlacementInput = control.FindChild("ItemPlacementInput") as TextBlock;
|
||||
indexInput = control.FindChild("IndexInput") as TextBox;
|
||||
itemPlacementInput = control.FindChild("ItemPlacementInput") as ComboBox;
|
||||
disableAnimationInput = control.FindChild("DisableAnimationInput") as CheckBox;
|
||||
scrollIfVisibileInput = control.FindChild("ScrollIfVisibileInput") as CheckBox;
|
||||
additionalHorizontalOffsetInput = control.FindChild("AdditionalHorizontalOffsetInput") as TextBlock;
|
||||
additionalVerticalOffsetInput = control.FindChild("AdditionalVerticalOffsetInput") as TextBlock;
|
||||
additionalHorizontalOffsetInput = control.FindChild("AdditionalHorizontalOffsetInput") as TextBox;
|
||||
additionalVerticalOffsetInput = control.FindChild("AdditionalVerticalOffsetInput") as TextBox;
|
||||
|
||||
if (sampleListView != null)
|
||||
{
|
||||
|
@ -51,12 +51,22 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
|
|||
{
|
||||
SampleController.Current.RegisterNewCommand("Start Smooth Scroll", (sender, args) =>
|
||||
{
|
||||
var index = int.Parse(indexInput?.Text);
|
||||
var itemPlacement = (ItemPlacement)Enum.Parse(typeof(ItemPlacement), itemPlacementInput?.Text);
|
||||
var disableAnimation = disableAnimationInput?.IsChecked ?? false;
|
||||
var scrollIfVisibile = scrollIfVisibileInput?.IsChecked ?? true;
|
||||
var additionalHorizontalOffset = int.Parse(additionalHorizontalOffsetInput?.Text);
|
||||
var additionalVerticalOffset = int.Parse(additionalVerticalOffsetInput?.Text);
|
||||
var index = int.TryParse(indexInput.Text, out var i) ? i : 0;
|
||||
var itemPlacement = itemPlacementInput.SelectedItem switch
|
||||
{
|
||||
"Default" => UI.ItemPlacement.Default,
|
||||
"Left" => UI.ItemPlacement.Left,
|
||||
"Top" => UI.ItemPlacement.Top,
|
||||
"Center" => UI.ItemPlacement.Center,
|
||||
"Right" => UI.ItemPlacement.Right,
|
||||
"Bottom" => UI.ItemPlacement.Bottom,
|
||||
_ => UI.ItemPlacement.Default
|
||||
};
|
||||
|
||||
var disableAnimation = disableAnimationInput.IsChecked ?? false;
|
||||
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;
|
||||
sampleListView.SmoothScrollIntoViewWithIndex(index, itemPlacement, disableAnimation, scrollIfVisibile, additionalHorizontalOffset, additionalVerticalOffset);
|
||||
});
|
||||
|
||||
|
|
|
@ -20,15 +20,14 @@
|
|||
</Page.Resources>
|
||||
|
||||
<Grid>
|
||||
<TextBlock x:Name="IndexInput" x:Load="False" Text="@[Index:Slider:100:0-200]" Visibility="Collapsed"></TextBlock>
|
||||
<TextBlock x:Name="ItemPlacementInput" x:Load="False" Text="@[Item Placement:Enum:ItemPlacement.Default]" Visibility="Collapsed"></TextBlock>
|
||||
<CheckBox x:Name="DisableAnimationInput" x:Load="False" IsChecked="@[Disable Animation:Bool:False]" Visibility="Collapsed"></CheckBox>
|
||||
<CheckBox x:Name="ScrollIfVisibileInput" x:Load="False" IsChecked="@[Scroll If Visibile:Bool:True]" Visibility="Collapsed"></CheckBox>
|
||||
<TextBlock x:Name="AdditionalHorizontalOffsetInput" x:Load="False" Text="@[Additional Horizontal Offset:Slider:0:-500-500]" Visibility="Collapsed"></TextBlock>
|
||||
<TextBlock x:Name="AdditionalVerticalOffsetInput" x:Load="False" Text="@[Additional Vertical Offset:Slider:0:-500-500]" Visibility="Collapsed"></TextBlock>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<ListView
|
||||
x:Name="SampleListView"
|
||||
Grid.Column="0"
|
||||
Margin="12"
|
||||
ItemTemplate="{StaticResource NormalTemplate}"
|
||||
IsItemClickEnabled="True"
|
||||
|
@ -37,5 +36,36 @@
|
|||
ui:ListViewExtensions.AlternateItemTemplate="{StaticResource AlternateTemplate}"
|
||||
ui:ListViewExtensions.ItemContainerStretchDirection="Both">
|
||||
</ListView>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="5,0,5,0" Width="200">
|
||||
<TextBox x:Name="IndexInput"
|
||||
Header="Index"
|
||||
InputScope="Number"
|
||||
Text="0" />
|
||||
<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>
|
Загрузка…
Ссылка в новой задаче