mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-02 04:52:09 +00:00
First scroll horizontally to the initial position to avoid the control crash bug
https://github.com/2dust/v2rayN/issues/7387
This commit is contained in:
parent
06500e0218
commit
cb6122f872
1 changed files with 19 additions and 1 deletions
|
@ -215,7 +215,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||||
await ViewModel.RefreshServersBiz();
|
await ViewModel.RefreshServersBiz();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lstProfiles.SelectedIndex > 0)
|
if (lstProfiles.SelectedIndex >= 0)
|
||||||
{
|
{
|
||||||
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, null);
|
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, null);
|
||||||
}
|
}
|
||||||
|
@ -347,6 +347,24 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||||
{
|
{
|
||||||
try
|
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)
|
foreach (var it in lstProfiles.Columns)
|
||||||
{
|
{
|
||||||
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
|
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
|
||||||
|
|
Loading…
Reference in a new issue