Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WinRT/UWP] Insert missing SendScrollFinished call #751

Merged
merged 1 commit into from Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,94 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Threading.Tasks;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

// Apply the default category of "Issues" to all of the tests in this assembly
// We use this as a catch-all for tests which haven't been individually categorized
#if UITEST
[assembly: NUnit.Framework.Category("Issues")]
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 44940, "[WinRT/UWP] ScrollView.ScrollToAsync does not return from await", PlatformAffected.WinRT)]
public class Bugzilla44940 : TestContentPage
{
Label _statusLabel;
Entry _firstEntry;
Entry _secondEntry;
StackLayout _verticalStackLayout;
ScrollView _scrollView;

protected override void Init()
{
_statusLabel = new Label
{
Text = "With focus on first Entry, hit Return key",
HorizontalOptions = LayoutOptions.CenterAndExpand,
LineBreakMode = LineBreakMode.WordWrap
};

_firstEntry = new Entry
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
};

_secondEntry = new Entry
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.CenterAndExpand,
};

_firstEntry.Completed += FirstEntryCompleted;

_verticalStackLayout = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Padding = new Thickness(0, 0, 0, 0),
Margin = new Thickness(0, 0, 0, 0),
Spacing = 5,
Children =
{
_statusLabel,
_firstEntry,
_secondEntry
}
};

_scrollView = new ScrollView
{
Orientation = ScrollOrientation.Vertical,
HorizontalOptions = LayoutOptions.CenterAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Margin = new Thickness(10, 5, 10, 0),
Padding = new Thickness(0, 0, 0, 0),
Content = _verticalStackLayout
};

Content = _scrollView;

Device.BeginInvokeOnMainThread(async () =>
{
await Task.Delay(100);
_firstEntry.Focus();
});
}

async void FirstEntryCompleted(object sender, System.EventArgs e)
{
_firstEntry?.Unfocus();
_statusLabel.Text = "Attempting scroll. Return from await pending...";
await _scrollView.ScrollToAsync(_secondEntry, ScrollToPosition.MakeVisible, false);
_statusLabel.Text = "This should be visible on WinRT/UWP";
_secondEntry?.Focus();
}
}
}
Expand Up @@ -149,6 +149,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43735.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43783.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44453.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44940.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44944.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44166.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44461.cs" />
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Platform.WinRT/ScrollViewRenderer.cs
Expand Up @@ -146,6 +146,7 @@ void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
{
Control.ChangeView(x, y, null, !e.ShouldAnimate);
}
Controller.SendScrollFinished();
}

void OnViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
Expand Down