-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Windows] Fix "PlatformView cannot be null here" Exception using VisualStates #27877
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.
Files not reviewed (2)
- src/Controls/tests/TestCases.HostApp/Issues/Issue27101.xaml: Language not supported
- src/Controls/tests/TestCases.HostApp/Issues/Issue27101SecondPage.xaml: Language not supported
Comments suppressed due to low confidence (1)
src/Controls/tests/TestCases.HostApp/Issues/Issue27101SecondPage.xaml.cs:10
- The OnNavigateBackButtonClicked method is not covered by tests. Add a test case to ensure this method works as expected.
async void OnNavigateBackButtonClicked(object sender, EventArgs e)
/rebase |
9eb04e5
to
2d65afd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this one has some relevant test failures?
I am kind of waiting for this fix. Would be nice if we can get this pr merged so it will be in the next version? |
/rebase |
a438029
to
85549cc
Compare
IsFocused ? VisualStateManager.CommonStates.Focused : VisualStateManager.CommonStates.Unfocused); | ||
} | ||
} | ||
catch(ObjectDisposedException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch(ObjectDisposedException) | |
catch (ObjectDisposedException) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder about this approach. The PR description mentions:
In the added sample, we have two pages, each with a Button to navigate forward and backward. Each Button is styled using VisualStates. After navigating back, ChangeVisualState is invoked which will invoke ButtonHandler.MapBackground. However, the button is null at this point, the handler has been disconnected.
So why is ChangeVisualState
called when the handler was disconnected?
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit: can be file-scoped namespace
This does not appear to be true. This PR adds a |
Description of Change
Fix "PlatformView cannot be null here" Exception using VisualStates on Windows.
In the added sample, we have two pages, each with a Button to navigate forward and backward. Each Button is styled using VisualStates. After navigating back,
ChangeVisualState
is invoked which will invokeButtonHandler.MapBackground
. However, the button is null at this point, the handler has been disconnected.The PR include changes to check if the
PlatformView
is not null and loaded before invoke theChangeVisualState
method.Issues Fixed
Fixes #27101