зеркало из https://github.com/DeGsoft/maui-linux.git
[UWP] Set ListView SelectedItem when constructing page (#1357)
This commit is contained in:
Родитель
aec4175c2d
Коммит
640e35526b
|
@ -0,0 +1,37 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 1356, "[UWP] A selected item in a ListView is not highlighted when constructing the page", PlatformAffected.UWP)]
|
||||
public class Issue1356 : TestContentPage
|
||||
{
|
||||
ObservableCollection<string> items = new ObservableCollection<string>() { "A", "B", "C" };
|
||||
|
||||
ListView listView;
|
||||
protected override void Init()
|
||||
{
|
||||
listView = new ListView
|
||||
{
|
||||
ItemsSource = items
|
||||
};
|
||||
|
||||
Content = new StackLayout
|
||||
{
|
||||
Children =
|
||||
{
|
||||
listView,
|
||||
new Label { Text = "Item 'B' should be highlighted when loading this page" }
|
||||
}
|
||||
};
|
||||
listView.SelectedItem = items[1];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -256,6 +256,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue1024.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1025.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1026.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1356.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue1691.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2983.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2963.cs" />
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
// 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 (Element.SelectedItem != null)
|
||||
OnElementItemSelected(null, new SelectedItemChangedEventArgs(Element.SelectedItem));
|
||||
|
||||
UpdateGrouping();
|
||||
UpdateHeader();
|
||||
UpdateFooter();
|
||||
|
|
Загрузка…
Ссылка в новой задаче