Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable combo box within a ListView's DataTemplate needs to be edited twice for the change to take effect #9240

Open
PankajBhojwani opened this issue Jan 11, 2024 · 0 comments
Labels
area-ComboBox bug Something isn't working team-Controls Issue for the Controls team

Comments

@PankajBhojwani
Copy link

PankajBhojwani commented Jan 11, 2024

Describe the bug

When using a ListView with a datatemplate that represents the items in editable combo boxes, the first time a custom value is entered into the combo box the custom value gets reset to the previous value. This only occurs if the custom value is overwriting a 'preset' value, it does not occur if the custom value is overwriting another custom value. The GIF explains this better.

Steps to reproduce the bug

Create a ListView in XAML like this:

            <!--StringVector is a vector of string values-->
            <ListView ItemsSource="{x:Bind StringVector}">
                <ListView.Resources>
                    <!--PresetCVS is the vector of preset allowed string values, for the combo box dropdown-->
                    <CollectionViewSource x:Key="PresetCVS"
                                          x:Name="PresetCVS" />
                </ListView.Resources>
                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="x:String">
                        <ComboBox IsEditable="True"
                                  IsSynchronizedWithCurrentItem="False"
                                  Text="{Binding}"
                                  ItemsSource="{Binding Source={StaticResource PresetCVS}}">
                        </ComboBox>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

In the code behind, initialize StringVector as an observable vector of strings, and populate PresetCVS with some 'preset' allowed string values. For example, this is what I did in c++:

        _PresetList = winrt::single_threaded_observable_vector<winrt::hstring>();
        _PresetList .Append(L"thisIsAPreset");
        _PresetList .Append(L"thisIsAnotherPreset");
        PresetCVS().Source(_PresetList);
        _StringVector_= winrt::single_threaded_observable_vector<winrt::hstring>();
        _StringVector_.Append(L"thisIsACustomValue");
        _StringVector_.Append(L"thisIsAPreset");

Then, run the application and try to edit the combo box that contains the preset value. Upon first try, the new value gets 'reset' to the previous value. Upon second try, the edit goes through successfully. This issue does not exist when editing the combo box that already contains a custom value.

Expected behavior

The change should go through upon the first try.

Screenshots

listViewComboBox

NuGet package version

None

Windows version

Windows Insider Build (xxxxx)

Additional context

No response

@PankajBhojwani PankajBhojwani added the bug Something isn't working label Jan 11, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 11, 2024
@bpulliam bpulliam added area-ComboBox team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ComboBox bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

2 participants