Skip to content

Preserve node editor traffic type selection#8

Merged
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator
Apr 7, 2026
Merged

Preserve node editor traffic type selection#8
wnj00524 merged 1 commit into
masterfrom
codex/wpf-network-simulator

Conversation

@wnj00524
Copy link
Copy Markdown
Owner

@wnj00524 wnj00524 commented Apr 7, 2026

No description provided.

@wnj00524 wnj00524 merged commit cf57eae into master Apr 7, 2026
0 of 2 checks passed
@wnj00524 wnj00524 deleted the codex/wpf-network-simulator branch April 7, 2026 21:03
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the RefreshTrafficTypeNameOptions method in MainWindowViewModel.cs to preserve the selected traffic type when the options collection is rebuilt. Feedback suggests handling potential case-sensitivity mismatches between the stored traffic type and the synchronized collection to ensure WPF correctly restores the selection.

Comment on lines +899 to +903
// Re-announce the current selection after rebuilding the options collection so WPF restores the combo value.
if (!string.IsNullOrWhiteSpace(selectedTrafficType))
{
OnPropertyChanged(nameof(SelectedNodeTrafficType));
}
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));
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant