CARVIEW |
Select Language
HTTP/2 200
date: Tue, 29 Jul 2025 05:12:56 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/dotnet/maui.git
etag: W/"60fa805ff8862b945b06f21b726c1488"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=lcxRQxlBIrxM3rkha%2B0oLR2YYYy49uijp%2BCvirUgpzZQrty5PdWfQiD1nxkcr9kWMupLKKkJb%2B%2FWh%2BOGS3jq8HGP1sLawyrWcra7qHtDcZPLxH%2F5iajIa2T%2BZVnmiVm87%2FLPw9%2BRG6gHN%2BCzzdYQz%2FVPbSS9gqzjbd6QerEcb5Aft9p6gGIuifofAMHKxN7PIXo51NvV%2Bv%2BQScPX9BuDNYvvhlxQGVYz3x%2FJEzWsVJYKnDXL189ucC40CfaiNNyhBFUB8r%2BIoLE4%2F4hiIVHERQ%3D%3D--DL%2BlKWJclVYrnRue--Ub42h8UrCANDmHtFzQMWcA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1219114661.1753765976; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 05:12:56 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 29 Jul 2026 05:12:56 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 8960:1CFCAC:3327FD:4671D3:68885858
[listview] fixes for various null/empty DataTemplate (#13146) Fixes: … · dotnet/maui@9ab7067 · GitHub
Copy file name to clipboardExpand all lines: src/Compatibility/Core/src/Android/VisualElementRenderer.cs
Copy file name to clipboardExpand all lines: src/Controls/src/Core/TemplatedItemsList.cs
Copy file name to clipboardExpand all lines: src/Controls/tests/DeviceTests/Elements/ListView/ListViewTests.cs
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit 9ab7067
authored
### Description of Change
Fixes: #11203
The following breaks XAML Hot Reload:
1. Setup a working `ListView` and `DataTemplate`
2. Delete the `DataTemplate`'s body (as if I'm about to type a
completely new view there).
3. Trigger a XAML Hot Reload. This can happen automatically if you just
pause typing.
4. MAUI crashes at runtime:
```
in Android.Views.ViewGroup.Layout at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Views.ViewGroup.cs:3369,5
in Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer<Microsoft.Maui.Controls.ListView>.OnLayout at D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\VisualElementRenderer.cs:54,6
in Microsoft.Maui.Controls.Handlers.Compatibility.ListViewRenderer.OnLayout at D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\ListView\Android\ListViewRenderer.cs:298,4
```
You can also create this problem in C#, like I did in a unit test:
listView.ItemTemplate = new DataTemplate(() => /* valid template */);
listView.ItemTemplate = new DataTemplate(); // broken
listView.ItemTemplate = new DataTemplate(() => null); //broken
I could also get a slightly different crash:
System.InvalidCastException: Specified cast is not valid.
at
Microsoft.Maui.Controls.Internals.TemplatedItemsList`2[[Microsoft.Maui.Controls.ItemsView`1[[Microsoft.Maui.Controls.Cell,
Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]], Microsoft.Maui.Controls, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Cell,
Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]].ActivateContent(Int32 index, Object item)
The "invalid cast" appears to be due to the changes in c57858f. It
returns a `new Label()` in some cases, which does not work with a
`ListView`. You need a `Cell` instead of `View` in that case.
The fixes appear to be in two places:
* `VisualElementRenderer.OnLayout`: use `is`, also simplifies the code
* `TemplatedItemsList.ActivateContent` : use `is` and call the default
data template.
Now my tests pass, and I can't reproduce the issue in XAML Hot Reload
either!
Manually testing, I'm able to alternative commenting out the two XAML
elements:


This didn't work before.
### Issues Fixed
Fixes: #11203
File tree
Expand file treeCollapse file tree
3 files changed
+65
-6
lines changedFilter options
- src
- Compatibility/Core/src/Android
- Controls
- src/Core
- tests/DeviceTests/Elements/ListView
Expand file treeCollapse file tree
3 files changed
+65
-6
lines changedsrc/Compatibility/Core/src/Android/VisualElementRenderer.cs
Copy file name to clipboardExpand all lines: src/Compatibility/Core/src/Android/VisualElementRenderer.cs+4-4Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
300 | 300 |
| |
301 | 301 |
| |
302 | 302 |
| |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
307 | 307 |
| |
308 | 308 |
| |
309 | 309 |
| |
|
src/Controls/src/Core/TemplatedItemsList.cs
Copy file name to clipboardExpand all lines: src/Controls/src/Core/TemplatedItemsList.cs+4-2Lines changed: 4 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
534 | 534 |
| |
535 | 535 |
| |
536 | 536 |
| |
537 |
| - | |
538 |
| - | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
539 | 541 |
| |
540 | 542 |
| |
541 | 543 |
| |
|
src/Controls/tests/DeviceTests/Elements/ListView/ListViewTests.cs
Copy file name to clipboardExpand all lines: src/Controls/tests/DeviceTests/Elements/ListView/ListViewTests.cs+57Lines changed: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| 23 | + | |
23 | 24 |
| |
24 | 25 |
| |
25 | 26 |
| |
| |||
152 | 153 |
| |
153 | 154 |
| |
154 | 155 |
| |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
155 | 212 |
| |
156 | 213 |
|
You can’t perform that action at this time.
0 commit comments