WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

Datagrid Template Columns not retaining values on some controls.

Open Wandtket opened this issue 2 years ago • 2 comments

Describe the bug

When using DataGridTemplateColumn and binding certain columns to an observable collection, custom template columns won't retain their values such as comboboxes, datepickers, and sometimes Autosuggest boxes.

Also when scrolling the Datagrid with large amounts of data it sometimes duplicates previous inputs.

Regression

No response

Reproducible in sample app?

  • [ ] This bug can be reproduced in the sample app.

Steps to reproduce

1. Create an observable collection
2. Bind to DataGrid
3. Add custom template columns
4. Add controls such as combobox, datepicker, etc to template
5. Try to add values to the control at runtime.

Expected behavior

Each row should maintain values set by the user until the Itemssource is updated.

Screenshots

2022-03-29-14-52-46

Windows Build Number

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [X] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [X] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Nuget packages

No response

Additional context

<!--Displaying static options combobox-->
                <controls:DataGridTemplateColumn x:Name="Combo" Header="ComboBox">
                    <controls:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox x:Name="StaticCombo" Width="150" SelectionChanged="Combo_SelectionChanged">
                                <ComboBoxItem Content="Do Something 1"/>
                                <ComboBoxItem Content="Do Something 2"/>
                                <ComboBoxItem Content="Do Something 3"/>
                            </ComboBox>
                        </DataTemplate>
                    </controls:DataGridTemplateColumn.CellTemplate>
                </controls:DataGridTemplateColumn>

Help us help you

No.

Wandtket avatar Mar 29 '22 20:03 Wandtket

Hello Wandtket, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

ghost avatar Mar 29 '22 20:03 ghost

I'm not sure if I follow the scenario you're trying to layout here @Wandtket.

Are you trying to make a distinction between edited data that hasn't been committed yet and the original source?

If so, there are additional interfaces like IEditableObject needed to support that, see docs here: https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/editing_inputvalidation

Can you confirm that your scenario for custom templated columns is using that interface as well?

Otherwise could you further break-down the required steps to reproduce this, the exact data you're seeing, and the exact data you would have expected performing those steps?

Reproducing this in our Sample App by changing the example or providing an isolated minimal repro would be helpful. Thanks.

michael-hawker avatar Apr 12 '22 19:04 michael-hawker