Auto expand scenery tree and autoselect first vehicle

This commit is contained in:
2026-06-23 18:47:18 +02:00
parent fe8ccbca8f
commit 1bfac8b222

View File

@@ -76,8 +76,21 @@ public partial class Scenarios : UserControl
{
var item = sceneryList.SelectedItem as TreeViewItem;
if (item?.Tag is not int tag)
{
foreach (TreeViewItem? toCollapse in sceneryList.Items)
{
if (toCollapse != null)
toCollapse.IsExpanded = false;
}
if (item != null)
item.IsExpanded = true;
if (item is { Items.Count: > 0 })
sceneryList.SelectedItem = item.Items[0];
return;
}
Scenery selectedScn = Sceneries[tag];
vehicleList.Items.Clear();
// scenery-level info (distinct from the per-consist scenario description)
@@ -103,6 +116,10 @@ public partial class Scenarios : UserControl
});
}
if (vehicleList.Items.Count > 0)
{
vehicleList.SelectedIndex = 0;
}
}
// Shows the selected scenery's description (//$d) and 1:1 image (//$i).