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

ToggleSwitch - commands triggered wrongly when grid is virtualized #2762

Closed
j-maly opened this issue Dec 10, 2016 · 3 comments · Fixed by #3756
Closed

ToggleSwitch - commands triggered wrongly when grid is virtualized #2762

j-maly opened this issue Dec 10, 2016 · 3 comments · Fixed by #3756
Assignees
Labels
Milestone

Comments

@j-maly
Copy link

j-maly commented Dec 10, 2016

What steps will reproduce this issue?

I put ToggleSwitches in standard WPF DataGrid. The grid uses row virtualization. I have also set CheckedCommand/UnCheckedCommand.
Now when the grid is rendered and I scroll in the grid, the check/unchecked commands get called.
I suspect this is caused by virtualization - when an already rendered control gets reused for another row which has the toggle set to the opposite value, the control is "toggled" and the command is triggered.
With virtualization off, this doesn't happen, but it is quite a significant performance hit in my case.

Expected outcome

Checked/UnChecked command should not be triggered since the underlying DataModel has not changed and the user hasn't toggled the switch.

Environment

  • MahApps.Metro 1.3.0
  • Windows 10
  • Visual Studio 2015
  • .NET Framework 4.5
@j-maly j-maly changed the title ToggleSwitch - commands triggered when grid is virtualized ToggleSwitch - commands triggered wrongly when grid is virtualized Dec 10, 2016
@punker76 punker76 self-assigned this Dec 15, 2016
@punker76 punker76 added the Bug label Dec 15, 2016
@punker76 punker76 modified the milestones: 1.4.0, 1.5.0 Dec 15, 2016
@punker76
Copy link
Member

I think this is a common problem of such controls (including checkbox columns), so a custom column could maybe fix this.

@punker76 punker76 removed the Bug label Apr 10, 2017
@punker76
Copy link
Member

@j-maly I tried to make a DataGridToggleSwitchColumn but get the same result, that the IsChecked property is set if the row is coming in to the view. I saw by inspected the DataGridCheckBoxColumn that this is also happening there, except the commands cause the CheckBox doesn't has this, but the IsChecked property is also set an unset like the ToggleSwitch. So I came to the point that this is maybe not fixable (not in an easy way).

@punker76
Copy link
Member

@j-maly The only way is to change these commands from value changed commands to only user changed commands (when the user clicked on it), but this is a breaking change.

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

Successfully merging a pull request may close this issue.

2 participants