-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with calling SwipeItems Clear function would crash (#1383)
* Add checks to fix bug with clearing swipeitems * Add test page * Add unit test for calling Clear on SwipeItems objects * Add vertical scroll items * Fix faulty unit test for SwipeItems crashing when calling clear
- Loading branch information
1 parent
2c8f540
commit 18ef85a
Showing
7 changed files
with
227 additions
and
4 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
94 changes: 94 additions & 0 deletions
94
dev/SwipeControl/SwipeControl_TestUI/SwipeControlClearPage.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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. --> | ||
<local:TestPage | ||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" | ||
x:Class="MUXControlsTestApp.SwipeControlClearPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:MUXControlsTestApp" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
||
|
||
<Grid> | ||
<Grid.Resources> | ||
<muxc:SwipeItems x:Name="DefaultSwipeItemsHorizontal" > | ||
<muxc:SwipeItem Background="Orange" BehaviorOnInvoked="RemainOpen"></muxc:SwipeItem> | ||
</muxc:SwipeItems> | ||
<muxc:SwipeItem x:Name="DefaultSwipeItemHorizontal" Background="Orange" BehaviorOnInvoked="RemainOpen"></muxc:SwipeItem> | ||
<muxc:SwipeItems x:Name="DefaultSwipeItemsVertical"> | ||
<muxc:SwipeItem Background="Orange" BehaviorOnInvoked="RemainOpen"></muxc:SwipeItem> | ||
</muxc:SwipeItems> | ||
<muxc:SwipeItem x:Name="DefaultSwipeItemVertical" Background="Orange" BehaviorOnInvoked="RemainOpen"></muxc:SwipeItem> | ||
</Grid.Resources> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"></RowDefinition> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" ></ColumnDefinition> | ||
<ColumnDefinition Width="Auto" ></ColumnDefinition> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Grid Grid.Row="0" Grid.Column="0" Margin="20"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="100"></RowDefinition> | ||
<RowDefinition Height="20"></RowDefinition> | ||
<RowDefinition Height="100"></RowDefinition> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="120"></ColumnDefinition> | ||
<ColumnDefinition Width="0"></ColumnDefinition> | ||
<ColumnDefinition Width="120"></ColumnDefinition> | ||
</Grid.ColumnDefinitions> | ||
<ListView Grid.Row="0" Grid.Column="0" x:Name="leftSwipe"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<muxc:SwipeControl LeftItems="{StaticResource DefaultSwipeItemsHorizontal}"> | ||
<Grid Background="Red" Width="100" Height="100" /> | ||
</muxc:SwipeControl> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
<ListView Grid.Row="0" Grid.Column="2" x:Name="topSwipe"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<muxc:SwipeControl TopItems="{StaticResource DefaultSwipeItemsVertical}"> | ||
<Grid Background="Green" Width="100" Height="100" /> | ||
</muxc:SwipeControl> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
<ListView Grid.Row="2" Grid.Column="0" x:Name="rightSwipe"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<muxc:SwipeControl RightItems="{StaticResource DefaultSwipeItemsHorizontal}"> | ||
<Grid Background="Blue" Width="100" Height="100" /> | ||
</muxc:SwipeControl> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
<ListView Grid.Row="2" Grid.Column="2" x:Name="bottomSwipe"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate> | ||
<muxc:SwipeControl BottomItems="{StaticResource DefaultSwipeItemsVertical}"> | ||
<Grid Background="Yellow" Width="100" Height="100"/> | ||
</muxc:SwipeControl> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
|
||
|
||
|
||
</Grid> | ||
|
||
<StackPanel Grid.Row="0" Grid.Column="1"> | ||
<Button Click="AddSwipeItemsButton_Click" x:Name="AddItemsButton" AutomationProperties.Name="AddItemsButton">Add SwipeItems</Button> | ||
<Button Click="ClearSwipeItemsButton_Click" x:Name="ClearItemsButton" AutomationProperties.Name="ClearItemsButton">Clear SwipeItems</Button> | ||
<TextBlock x:Name="SwipeItemsChildSum" AutomationProperties.Name="SwipeItemsChildSum" ></TextBlock> | ||
</StackPanel> | ||
|
||
</Grid> | ||
</local:TestPage> |
50 changes: 50 additions & 0 deletions
50
dev/SwipeControl/SwipeControl_TestUI/SwipeControlClearPage.xaml.cs
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,50 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
using System; | ||
using Windows.UI.Xaml; | ||
|
||
namespace MUXControlsTestApp | ||
{ | ||
/// <summary> | ||
/// Test page used for clearing existing SwipeControls | ||
/// </summary> | ||
public sealed partial class SwipeControlClearPage : TestPage | ||
{ | ||
private string[] items = new string[] { "some text" }; | ||
|
||
public SwipeControlClearPage() | ||
{ | ||
this.InitializeComponent(); | ||
SwipeItemsChildSum.Text = (DefaultSwipeItemsHorizontal.Count + DefaultSwipeItemsVertical.Count).ToString(); | ||
|
||
leftSwipe.ItemsSource = items; | ||
topSwipe.ItemsSource = items; | ||
rightSwipe.ItemsSource = items; | ||
bottomSwipe.ItemsSource = items; | ||
} | ||
|
||
public void AddSwipeItemsButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DefaultSwipeItemsHorizontal.Clear(); | ||
DefaultSwipeItemsVertical.Clear(); | ||
|
||
DefaultSwipeItemsHorizontal.Mode = Microsoft.UI.Xaml.Controls.SwipeMode.Reveal; | ||
DefaultSwipeItemsHorizontal.Add(DefaultSwipeItemHorizontal); | ||
|
||
// Using swipecontrol inside datatemplate prevents us from setting that: | ||
// Swipecontrol is in horizontal mode, can not add vertical swipe items... | ||
//DefaultSwipeItemsVertical.Mode = Microsoft.UI.Xaml.Controls.SwipeMode.Reveal; | ||
//DefaultSwipeItemsVertical.Add(DefaultSwipeItemVertical); | ||
|
||
SwipeItemsChildSum.Text = (DefaultSwipeItemsHorizontal.Count + DefaultSwipeItemsVertical.Count).ToString(); | ||
} | ||
public void ClearSwipeItemsButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
DefaultSwipeItemsHorizontal.Clear(); | ||
DefaultSwipeItemsVertical.Clear(); | ||
SwipeItemsChildSum.Text = (DefaultSwipeItemsHorizontal.Count + DefaultSwipeItemsVertical.Count).ToString(); | ||
} | ||
|
||
} | ||
} |
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
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