summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-06-08 13:38:08 -0400
committerJason Smith <jason.smith@xamarin.com>2016-06-08 10:38:08 -0700
commitce0238846a5aa9436d2d7a79682688511473f595 (patch)
tree40ff7dd4a29312ad2c5bada1ce252a31e97aaefc
parent2a244e0b2fc793f9d58ee517b6e73350583756b0 (diff)
downloadxamarin-forms-ce0238846a5aa9436d2d7a79682688511473f595.tar.gz
xamarin-forms-ce0238846a5aa9436d2d7a79682688511473f595.tar.bz2
xamarin-forms-ce0238846a5aa9436d2d7a79682688511473f595.zip
[Win 8.1] Initial ListView selection not shown (#174)
On Windows 8.1, when initially setting a ListView's SelectedItem, the item in question would not have any visual indication that it was selected when first showing (a background color for the cell). Subsequent selections would work as expected.
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41078.cs36
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs6
3 files changed, 43 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41078.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41078.cs
new file mode 100644
index 00000000..0c915331
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41078.cs
@@ -0,0 +1,36 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+using System.Collections.Generic;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 41078, "[Win 8.1] ListView not visually setting the initial SelectedItem upon creation", PlatformAffected.WinRT)]
+ public class Bugzilla41078 : TestContentPage
+ {
+ protected override void Init()
+ {
+ var list = new List<int> { 1, 2, 3 };
+ var listView = new ListView
+ {
+ ItemsSource = list,
+ SelectedItem = list[1]
+ };
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label { Text = "The '2' cell should have a background color indicating it is selected" },
+ listView
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 2a8db8fb..991270b6 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -104,6 +104,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40185.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40333.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla31806.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41078.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
diff --git a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs
index bbd101fa..d47299a4 100644
--- a/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/ListViewRenderer.cs
@@ -83,6 +83,12 @@ namespace Xamarin.Forms.Platform.WinRT
// WinRT throws an exception if you set ItemsSource directly to a CVS, so bind it.
List.DataContext = new CollectionViewSource { Source = Element.ItemsSource, IsSourceGrouped = Element.IsGroupingEnabled };
+#if !WINDOWS_UWP
+ var selected = Element.SelectedItem;
+ if (selected != null)
+ OnElementItemSelected(null, new SelectedItemChangedEventArgs(selected));
+#endif
+
UpdateGrouping();
UpdateHeader();
UpdateFooter();