зеркало из https://github.com/DeGsoft/maui-linux.git
added case in GTK listviewrendered for change of SelectedItem property (#4757)
This commit is contained in:
Родитель
57d507ef0b
Коммит
81c9a5256c
|
@ -0,0 +1,39 @@
|
|||
using System.Collections.Generic;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 4748, "Setting SelectedItem property of GTK ListView does not reflected in UI", PlatformAffected.Default)]
|
||||
public class Issue4748 : TestContentPage
|
||||
{
|
||||
protected override void Init()
|
||||
{
|
||||
var layout = new StackLayout();
|
||||
var lastItem = "Item3";
|
||||
var listView = new ListView
|
||||
{
|
||||
ItemsSource = new List<string>
|
||||
{
|
||||
"Item1",
|
||||
"Item2",
|
||||
lastItem
|
||||
}
|
||||
};
|
||||
|
||||
var button = new Button
|
||||
{
|
||||
Text = "Select last item",
|
||||
AutomationId = "SelectLastItem"
|
||||
};
|
||||
|
||||
button.Clicked += (_, __) => listView.SelectedItem = lastItem;
|
||||
layout.Children.Add(listView);
|
||||
layout.Children.Add(button);
|
||||
|
||||
Content = layout;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -548,6 +548,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue3988.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue2580.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue4026.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue4748.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla56298.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42620.cs" />
|
||||
|
|
|
@ -95,6 +95,8 @@ namespace Xamarin.Forms.Platform.GTK.Renderers
|
|||
UpdateIsRefreshing();
|
||||
else if (e.PropertyName == ListView.IsPullToRefreshEnabledProperty.PropertyName)
|
||||
UpdatePullToRefreshEnabled();
|
||||
else if (e.PropertyName == ListView.SelectedItemProperty.PropertyName)
|
||||
UpdateSelectedItem();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
@ -436,6 +438,11 @@ namespace Xamarin.Forms.Platform.GTK.Renderers
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateSelectedItem()
|
||||
{
|
||||
_listView?.SetSeletedItem(Element.SelectedItem);
|
||||
}
|
||||
|
||||
private void UpdateGrouping()
|
||||
{
|
||||
var templatedItems = TemplatedItemsView.TemplatedItems;
|
||||
|
|
Загрузка…
Ссылка в новой задаче