Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/MedWNetworkSim.App/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ private void RefreshNodeIdOptions()

private void RefreshTrafficTypeNameOptions()
{
var selectedTrafficType = SelectedNodeTrafficProfile?.TrafficType;
var trafficTypeNames = TrafficDefinitions
.Select(definition => definition.Name)
.Concat(Nodes.SelectMany(node => node.TrafficProfiles).Select(profile => profile.TrafficType))
Expand All @@ -894,6 +895,12 @@ private void RefreshTrafficTypeNameOptions()
.OrderBy(name => name, Comparer);

SynchronizeCollection(TrafficTypeNameOptions, trafficTypeNames);

// Re-announce the current selection after rebuilding the options collection so WPF restores the combo value.
if (!string.IsNullOrWhiteSpace(selectedTrafficType))
{
OnPropertyChanged(nameof(SelectedNodeTrafficType));
}
Comment on lines +899 to +903
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The selection restoration might fail if the casing of the traffic type in the TrafficTypeNameOptions collection differs from the selectedTrafficType captured from the profile. Since the collection is built using a case-insensitive Distinct(Comparer), it may contain a version of the string with different casing (e.g., "ABC" instead of "abc"). WPF's SelectedItem matching is case-sensitive, so it won't automatically restore the selection if the casing doesn't match exactly. Consider ensuring the profile's TrafficType is updated to match the casing found in the synchronized collection.

        // Re-announce the current selection after rebuilding the options collection so WPF restores the combo value.
        if (!string.IsNullOrWhiteSpace(selectedTrafficType))
        {
            var matchedType = TrafficTypeNameOptions.FirstOrDefault(name => Comparer.Equals(name, selectedTrafficType));
            if (matchedType != null && SelectedNodeTrafficProfile != null)
            {
                SelectedNodeTrafficProfile.TrafficType = matchedType;
            }

            OnPropertyChanged(nameof(SelectedNodeTrafficType));
        }

}

private void RefreshEdgeBindings()
Expand Down
Loading