зеркало из https://github.com/DeGsoft/maui-linux.git
[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.
This commit is contained in:
Родитель
2a244e0b2f
Коммит
ce0238846a
|
@ -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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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" />
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче