First scroll horizontally to the initial position to avoid the control crash bug
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run

https://github.com/2dust/v2rayN/issues/7387
This commit is contained in:
2dust 2025-06-16 10:48:35 +08:00
parent 06500e0218
commit cb6122f872

View file

@ -215,7 +215,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
await ViewModel.RefreshServersBiz();
}
if (lstProfiles.SelectedIndex > 0)
if (lstProfiles.SelectedIndex >= 0)
{
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, null);
}
@ -347,6 +347,24 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
{
try
{
//First scroll horizontally to the initial position to avoid the control crash bug
if (lstProfiles.SelectedIndex >= 0)
{
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, lstProfiles.Columns[0]);
}
else
{
var model = lstProfiles.ItemsSource.Cast<ProfileItemModel>();
if (model.Any())
{
lstProfiles.ScrollIntoView(model.First(), lstProfiles.Columns[0]);
}
else
{
return;
}
}
foreach (var it in lstProfiles.Columns)
{
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);