diff --git a/src/System.Windows.Forms/src/Resources/SR.resx b/src/System.Windows.Forms/src/Resources/SR.resx
index c037a1948a0..81f39dbea3b 100644
--- a/src/System.Windows.Forms/src/Resources/SR.resx
+++ b/src/System.Windows.Forms/src/Resources/SR.resx
@@ -6722,7 +6722,4 @@ Stack trace where the illegal operation occurred was:
Double Click
-
- The ListView group that currently has the user focus.
-
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf
index fad6a170753..447989799cf 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.cs.xlf
@@ -6346,11 +6346,6 @@ Trasování zásobníku, kde došlo k neplatné operaci:
Vlastnost FindNearestItem je podporována pouze v případě, že vlastnost ListView je v zobrazení SMALLICON nebo LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- Položka zobrazení ListView, na níž je nyní nastaven fokus uživatele
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf
index e342160faed..14f40d70a1f 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.de.xlf
@@ -6346,11 +6346,6 @@ Stapelüberwachung, in der der unzulässige Vorgang auftrat:
FindNearestItem wird nur unterstützt, wenn sich die ListView in der SMALLICON- oder LARGEICON-Ansicht befindet.
-
-
- The ListView group that currently has the user focus.
-
- Das ListView-Element, das zurzeit den Benutzerfokus hat.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf
index 01d0fa1e34b..cb263b07cec 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.es.xlf
@@ -6346,11 +6346,6 @@ El seguimiento de la pila donde tuvo lugar la operación no válida fue:
FindNearestItem se admite sólo cuando ListView está en las vistas SMALLICON o LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- Elemento ListView que tiene el foco del usuario actualmente.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf
index ddda7f235d5..0b82d7858e7 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.fr.xlf
@@ -6346,11 +6346,6 @@ Cette opération non conforme s'est produite sur la trace de la pile :
FindNearestItem est pris en charge uniquement lorsque le ListView est en mode SMALLICON ou LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- L'élément ListView qui a actuellement le focus utilisateur.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf
index 97b69efa393..f1c7277b58a 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.it.xlf
@@ -6346,11 +6346,6 @@ Traccia dello stack da cui si è verificata l'operazione non valida:
FindNearestItem è supportato solo quando ListView è in vista SMALLICON o LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- La voce del controllo ListView che ha lo stato attivo.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf
index 5966bc4bf3b..08fa196705a 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ja.xlf
@@ -6346,11 +6346,6 @@ Stack trace where the illegal operation occurred was:
FindNearestItem は、ListView が SMALLICON または LARGEICON ビューであるときにのみサポートされます。
-
-
- The ListView group that currently has the user focus.
-
- 現在ユーザーがフォーカスしている ListView ビュー項目です。
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf
index f7e7a8b24ad..e5b4c785fc8 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ko.xlf
@@ -6346,11 +6346,6 @@ Stack trace where the illegal operation occurred was:
FindNearestItem은 ListView가 SMALLICON 또는 LARGEICON 보기에 있는 경우에만 지원됩니다.
-
-
- The ListView group that currently has the user focus.
-
- 현재 사용자 포커스가 있는 ListView 항목입니다.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf
index 480a0a76300..c69566060c9 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pl.xlf
@@ -6346,11 +6346,6 @@ Stos śledzenia, w którym wystąpiła zabroniona operacja:
Element FindNearestItem jest obsługiwany tylko wtedy, gdy element ListView jest w widoku SMALLICON lub LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- Element ListView, który aktualnie ma fokus.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf
index a4081a35ec1..25a00f6cb55 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.pt-BR.xlf
@@ -6346,11 +6346,6 @@ Rastreamento de pilha em que a operação ilegal ocorreu:
Somente há suporte para FindNearestItem quando ListView está na exibição SMALLICON ou LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- O item de ListView que tem atualmente o foco do usuário.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf
index bf437a18a40..9d421308515 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.ru.xlf
@@ -6347,11 +6347,6 @@ Stack trace where the illegal operation occurred was:
FindNearestItem поддерживается, только когда для ListView используется представление SMALLICON или LARGEICON.
-
-
- The ListView group that currently has the user focus.
-
- Текущий элемент ListView, на который пользователь переключил фокус.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf
index 4c44f4cb819..d018443526c 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.tr.xlf
@@ -6346,11 +6346,6 @@ Geçersiz işlemin gerçekleştiği yığın izi:
FindNearestItem yalnızca ListView SMALLICON veya LARGEICON görünümünde olduğunda desteklenir.
-
-
- The ListView group that currently has the user focus.
-
- Şu anda kullanıcı odağına sahip olan ListView öğesi.
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf
index fd276748430..d6dddccf17f 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hans.xlf
@@ -6346,11 +6346,6 @@ Stack trace where the illegal operation occurred was:
仅当 ListView 在 SMALLICON 或 LARGEICON 视图中时才支持 FindNearestItem。
-
-
- The ListView group that currently has the user focus.
-
- 当前具有用户焦点的 ListView 项。
diff --git a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf
index 40268b29cad..8f6154077e2 100644
--- a/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf
+++ b/src/System.Windows.Forms/src/Resources/xlf/SR.zh-Hant.xlf
@@ -6346,11 +6346,6 @@ Stack trace where the illegal operation occurred was:
只有當 ListView 處於 SMALLICON 或 LARGEICON 檢視時,才能支援 FindNearestItem。
-
-
- The ListView group that currently has the user focus.
-
- 目前有使用者焦點的 ListView 項目。
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
index 754c5c17f90..88ac6937c83 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
@@ -266,14 +266,13 @@ internal override UiaCore.IRawElementProviderSimple[] GetSelection()
return Array.Empty();
}
- List selectedItemProviders = new List();
- SelectedListViewItemCollection selectedItems = _owningListView.SelectedItems;
- foreach (ListViewItem selectedItem in selectedItems)
+ UiaCore.IRawElementProviderSimple[] selectedItemProviders = new UiaCore.IRawElementProviderSimple[_owningListView.SelectedItems.Count];
+ for (int i = 0; i < selectedItemProviders.Length; i++)
{
- selectedItemProviders.Add(selectedItem.AccessibilityObject);
+ selectedItemProviders[i] = _owningListView.SelectedItems[i].AccessibilityObject;
}
- return selectedItemProviders.ToArray();
+ return selectedItemProviders;
}
public override AccessibleObject? HitTest(int x, int y)
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs
index e21d8de6a58..a38f2751205 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListView.cs
@@ -153,7 +153,7 @@ public partial class ListView : Control
private CheckedIndexCollection checkedIndexCollection;
private CheckedListViewItemCollection checkedListViewItemCollection;
private SelectedListViewItemCollection selectedListViewItemCollection;
- internal SelectedIndexCollection selectedIndexCollection;
+ private SelectedIndexCollection selectedIndexCollection;
private ListViewGroupCollection groups;
private ListViewInsertionMark insertionMark;
private LabelEditEventHandler onAfterLabelEdit;
@@ -824,10 +824,6 @@ internal bool ExpectingMouseUp
/// group that's drawn with the dotted focus rectangle around it.
/// Returns null if no group is currently focused.
///
- [SRCategory(nameof(SR.CatAppearance))]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [SRDescription(nameof(SR.ListViewFocusedGroupDescription))]
internal ListViewGroup FocusedGroup
{
get => IsHandleCreated ? focusedGroup : null;
@@ -5908,7 +5904,7 @@ private void WmMouseDown(ref Message m, MouseButtons button, int clicks)
}
Point screenPoint = PointToScreen(new Point(x, y));
- AccessibleObject accessibilityObject = (AccessibilityObject as ListViewAccessibleObject).HitTest(screenPoint.X, screenPoint.Y);
+ AccessibleObject accessibilityObject = AccessibilityObject.HitTest(screenPoint.X, screenPoint.Y);
accessibilityObject?.RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId);
}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs
index c387dd744b6..1ea562dc7db 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs
@@ -83,7 +83,7 @@ internal AccessibleObject? AccessibilityObject
{
if (_accessibilityObject is null)
{
- _accessibilityObject = new ListViewGroupAccessibleObject(this, IsDefault);
+ _accessibilityObject = new ListViewGroupAccessibleObject(this, ListView?.Groups.Contains(this) == false);
}
return _accessibilityObject;
@@ -188,19 +188,6 @@ public HorizontalAlignment FooterAlignment
internal bool Focused { get; set; }
- private bool IsDefault
- {
- get
- {
- if (ListView is null || ListView.Groups.Contains(this))
- {
- return false;
- }
-
- return true;
- }
- }
-
///
/// Controls which the group will appear as.
///
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemAccessibleObject.cs
index 1d2a4276938..966e31ec611 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemAccessibleObject.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemAccessibleObject.cs
@@ -282,9 +282,9 @@ internal override void ScrollIntoView()
internal unsafe override void SelectItem()
{
- if (_owningListView.IsHandleCreated && _owningListView.selectedIndexCollection != null)
+ if (_owningListView.IsHandleCreated)
{
- _owningListView.selectedIndexCollection.Add(CurrentIndex);
+ _owningListView.SelectedIndices.Add(CurrentIndex);
User32.InvalidateRect(new HandleRef(this, _owningListView.Handle), null, BOOL.FALSE);
}
diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs
index bc5235dd6b8..4dcc9ec0c39 100644
--- a/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs
+++ b/src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObject.cs
@@ -29,11 +29,25 @@ internal override UiaCore.IRawElementProviderFragmentRoot FragmentRoot
=> _owningListView.AccessibilityObject;
public override Rectangle Bounds
- => new Rectangle(
+ {
+ get
+ {
+ // Previously bounds was provided using MSAA,
+ // but using UIA we found out that SendMessageW work incorrectly.
+ // When we need to get bounds for first sub item it will return width of all item.
+ int width = _owningSubItem.Bounds.Width;
+
+ if (Column == 0 && _owningItem.SubItems.Count > 1)
+ {
+ width = _owningItem.SubItems[Column + 1].Bounds.X - _owningSubItem.Bounds.X;
+ }
+
+ return new Rectangle(
_owningListView.AccessibilityObject.Bounds.X + _owningSubItem.Bounds.X,
_owningListView.AccessibilityObject.Bounds.Y + _owningSubItem.Bounds.Y,
- _owningSubItem.Bounds.Width,
- _owningSubItem.Bounds.Height);
+ width, _owningSubItem.Bounds.Height);
+ }
+ }
internal override UiaCore.IRawElementProviderFragment? FragmentNavigate(UiaCore.NavigateDirection direction)
{
@@ -65,7 +79,7 @@ public override Rectangle Bounds
///
public override string? Name
{
- get => _owningSubItem.Text;
+ get => base.Name ?? _owningSubItem.Text;
set => base.Name = value;
}
diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListVIew.ListViewAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListVIew.ListViewAccessibleObjectTests.cs
index 5bc11dab5fd..6426909b2f9 100644
--- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListVIew.ListViewAccessibleObjectTests.cs
+++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListVIew.ListViewAccessibleObjectTests.cs
@@ -31,6 +31,34 @@ public void ListViewAccessibleObject_EmptyList_GetChildCount_ReturnsCorrectValue
Assert.Equal(0, accessibleObject.GetChildCount()); // listView doesn't have items
}
+ [WinFormsFact]
+ public void ListViewAccessibleObject_GetMultiViewProviderCurrentView_ReturnsCorrectValue()
+ {
+ using ListView listView = new ListView();
+ AccessibleObject accessibleObject = listView.AccessibilityObject;
+ Assert.True(listView.IsHandleCreated);
+ Assert.Equal((int)listView.View, accessibleObject.GetMultiViewProviderCurrentView());
+ }
+
+ [WinFormsFact]
+ public void ListViewAccessibleObject_GetMultiViewProviderSupportedViews_ReturnsExpected()
+ {
+ using ListView listView = new ListView();
+ AccessibleObject accessibleObject = listView.AccessibilityObject;
+ Assert.True(listView.IsHandleCreated);
+ Assert.Equal(new int[] { (int)View.Details }, accessibleObject.GetMultiViewProviderSupportedViews());
+ }
+
+ [WinFormsFact]
+ public void ListViewAccessibleObject_GetMultiViewProviderViewName_ReturnsCorrectValue()
+ {
+ using ListView listView = new ListView();
+ listView.View = View.Details;
+ AccessibleObject accessibleObject = listView.AccessibilityObject;
+ Assert.True(listView.IsHandleCreated);
+ Assert.Equal(((int)(listView.View)).ToString(), accessibleObject.GetMultiViewProviderViewName((int)View.Details));
+ }
+
[WinFormsFact]
public void ListViewAccessibleObject_ListWithOneItem_GetChildCount_ReturnsCorrectValue()
{
diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObjectTests.cs
index 99d11a6e2b5..d20681818b1 100644
--- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObjectTests.cs
+++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObjectTests.cs
@@ -123,7 +123,7 @@ public void ListViewGroupAccessibleObject_ListWithTwoGroups_FragmentNavigateWork
Assert.Equal(firstChild, listItem3.AccessibilityObject);
}
- [WinFormsFact(Skip = "Crash with AbandonedMutexException. See: https://github.com/dotnet/arcade/issues/5325")]
+ [WinFormsFact]
public void ListViewGroupAccessibleObject_Bounds_ReturnsCorrectValue()
{
using RemoteInvokeHandle invokerHandle = RemoteExecutor.Invoke(() =>
@@ -143,7 +143,6 @@ public void ListViewGroupAccessibleObject_Bounds_ReturnsCorrectValue()
list.CreateControl();
form.Controls.Add(list);
form.Show();
- Thread.Sleep(40000);
AccessibleObject accessibleObject = list.AccessibilityObject;
AccessibleObject group1AccObj = listGroup.AccessibilityObject;
diff --git a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs
index f59ae51b317..365bbdcb4d9 100644
--- a/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs
+++ b/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewItem.ListViewSubItem.ListViewSubItemAccessibleObjectTests.cs
@@ -154,7 +154,7 @@ public void ListViewSubItemAccessibleObject_Bounds_ReturnCorrectValue()
Assert.True(list.IsHandleCreated);
int actualWidth = accessibleObject.Bounds.Width;
- int expectedWidth = subItem.Bounds.Width;
+ int expectedWidth = listViewItem1.SubItems[1].Bounds.X - subItem.Bounds.X;
Assert.Equal(expectedWidth, actualWidth);
int actualHeight = accessibleObject.Bounds.Height;
@@ -163,7 +163,7 @@ public void ListViewSubItemAccessibleObject_Bounds_ReturnCorrectValue()
Rectangle actualBounds = accessibleObject.Bounds;
actualBounds.Location = new Point(0, 0);
- Rectangle expectedBounds = subItem.Bounds;
+ Rectangle expectedBounds = new Rectangle(subItem.Bounds.X, subItem.Bounds.Y, expectedWidth, expectedHeight);
expectedBounds.Location = new Point(0, 0);
Assert.Equal(expectedBounds, actualBounds);
}