From ca3e80a7816850cbe2fcd6f6bf1c84d4223d4374 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Sun, 13 Aug 2017 04:03:46 +0900 Subject: [PATCH] =?utf8?q?ListView.set=5FTopItem=E5=86=85=E9=83=A8?= =?utf8?q?=E3=81=A7NullReferenceException=E3=81=8C=E7=99=BA=E7=94=9F?= =?utf8?q?=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C=E3=81=AB=E5=AF=BE=E5=87=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 原因は未だ不明なものの、内部で ListView.get_TopItem が null を返していると考えられる。 例外が発生した場合は EnsureVisible を二回呼び出してスクロールする。 https://osdn.net/ticket/browse.php?group_id=6526&tid=36219 Fixes: 1da38617 ("発言一覧の表示位置の固定に ListView.TopItem を使用する") --- OpenTween/Tween.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 15daa764..2310f111 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -1630,7 +1630,18 @@ namespace OpenTween case ScrollLockMode.FixedToItem: var topIndex = listScroll.TopItemStatusId != null ? tab.IndexOf(listScroll.TopItemStatusId.Value) : -1; if (topIndex != -1) - listView.TopItem = listView.Items[topIndex]; + { + var topItem = listView.Items[topIndex]; + try + { + listView.TopItem = topItem; + } + catch (NullReferenceException) + { + listView.EnsureVisible(listView.VirtualListSize - 1); + listView.EnsureVisible(topIndex); + } + } break; case ScrollLockMode.None: default: -- 2.11.0