-
Notifications
You must be signed in to change notification settings - Fork 701
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
Check Box Click Event Not Fired when added in a ContentDialog in WINUI #9343
Comments
Hi team, Is there any update on this? |
The issue here is that you are removing the click handler in the Unloaded event and we have confirmed that there are currently some issues with the way the Loading/Loaded/Unloaded events are raised when an item is removed and then re-added to the tree in a single frame. Unfortunately, we have not found a way to correct this issue without potentially breaking applications that may have inadvertently relied upon this behavior (including some internal Xaml code). Because of this, we will try to target a fix for the 2.0 release, but until then you will need to work around the issue and fortunately there appears to be such a workaround. What is happening is that the Unloaded event is getting fired asynchronously when the control is removed from the tree. But then it gets re-added and, by the time the event is actually processed by the application, the element is back in tree. To get around this issue, the application can look at the IsLoaded property on the element and only remove the handler if the value is false. Since the element is, in fact, in the tree, another Unloaded event will come when it is removed a second time. Details: First a bit of a side as to why this checkbox is getting removed and re-added. When content dialog is shown, it ends up being added to the tree (causing anything in it to be added to the tree), but then after the smoke layer is created (which happens during template application), it gets removed and re-added to ensure the correct z-order between the dialog content and the smoke layer. So from the perspective of a control, it gets added-removed-added, causing this issue. Now to the events. Because of the nature of these tree related events, they are raised at different times and in different manners in order to assure that things get manipulated predictably (which they are, it just seems no correctly). For example, Loading and Loaded are raised synchronously since an application might want to modify the tree in them and want to limit the amount of stale UI we render. But Unloaded, is asynchronous since is primarily just resource cleanup and there is o need to delay a render frame for it. So basically, what happens is:
The issue occurs if you add then remove, then re-add the element in the same tick. Here is what happens:
So now we have a unloaded event fired while the element is in the tree, thus causing this issue. The fix: Although we are still discussing options, we think the fix is that we would ensure that we don't raise an Unloaded event:
It is the first condition that we found breaks some internal code and could potentially break some applications. We are going to close this issue with the work around. However, there a number of other open cause by this sequence of events that may not have a workaround and we hope to fix and resolve those in 2.0. |
Describe the bug
The CheckBox click event is not fired when the checkbox is added in the contentDialog. Upon analysis, it was found that the CheckBox is unloaded before updating the view. Therefore, the CheckBox click event is not fired.
Steps to reproduce the bug
1.Run the sample.
2.Add the breakpoints in the Checkbox click event, Loaded event and Unloaded event.
3.Click the "Click Here" Button.
WINUI_Sample.zip
Expected behavior
The checkbox event should be triggered when the checkbox is clicked.
Screenshots
CheckBox_Query.mp4
NuGet package version
None
Windows version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: