perf: 战斗列表添加作业时自动滚动到添加位置 (#8455)

perf: 战斗列表添加作业时自动滚动到添加位置
This commit is contained in:
status102
2024-03-04 18:38:35 +08:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
// </copyright>
using System;
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
@@ -66,6 +67,19 @@ namespace MaaWpfGui.Styles.Properties
scrollViewer.ScrollChanged -= ScrollChanged;
}
}
else if (d is ListBox listBox)
{
INotifyCollectionChanged view = listBox.Items;
view.CollectionChanged += (sender, arg) =>
{
switch (arg.Action)
{
case NotifyCollectionChangedAction.Add:
listBox.ScrollIntoView(listBox.Items[arg.NewStartingIndex]);
break;
}
};
}
else
{
throw new InvalidOperationException("The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances.");

View File

@@ -201,6 +201,7 @@
dd:DragDrop.IsDragSource="{Binding Idle}"
dd:DragDrop.IsDropTarget="{Binding Idle}"
hc:BorderElement.CornerRadius="4,4,0,0"
properties:AutoScroll.AutoScroll="True"
BorderThickness="1,1,1,0"
DragDrop.Drop="{s:Action CopilotItemIndexChanged}"
IsEnabled="{c:Binding StartEnabled}"