fix: ComboBox default selection - use collection item reference#38
Merged
Conversation
- Initialize Config.Platform/AppType from Platforms[0]/AppTypes[0] in VM - Remove SelectedIndex=0 from XAML (conflicts with SelectedItem binding) - Ensures selected item IS a collection item, not a separate instance
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect default selection behavior in the Simulate view’s ComboBox controls by ensuring SelectedItem is set to the same object instances contained in the ItemsSource collections (avoiding reference-mismatch selection failures in Avalonia).
Changes:
- Removed
SelectedIndex="0"from the Platform/AppTypeComboBoxcontrols to avoid conflicting withSelectedItembindings. - Initialized
Config.PlatformandConfig.AppTypeinSimulateViewModeltoPlatforms[0]/AppTypes[0](the actual collection item references).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Views/SimulateView.axaml |
Removes SelectedIndex so SelectedItem binding is the single source of truth for selection. |
src/ViewModels/SimulateViewModel.cs |
Sets default Config selections to the ItemsSource instances to ensure Avalonia can resolve the selected item. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: ComboBox default selection error.
Root cause: Config.Platform was initialized as new PlatformItem(1,Windows) in the model, but Avalonia's ComboBox uses reference equality to find the selected item in ItemsSource. Even though PlatformItem is a record with value equality, the ComboBox couldn't match them.
Fix:
Build: 0 errors