-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
XAML error is shown when the content of a DataTemplate is not a View #22485
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
@mgoertz-msft @StephaneDelcroix thoughts? |
What is the property type of DataTemplate.DataTemplateContent? Is MyTabViewItem assignable to it? |
Yes, it is assignable, the sample runs correctly. It's just the shown error that casts doubt. The signature of the method in the DataTemplate is object CreateContent() (link). And in my case a tab-item is a BindableObject. |
Sorry, this was just now brought again to my attention. We don't usually look here for VS tooling bugs. Creating a Developer Community ticket in those cases is a better way to track issues with VS. I created the following bug for VS for this: Bug AB#2199135: XAML error is shown when the content of a DataTemplate is not a View |
The AzDO bug report was closed as fixed on 8/13 and is slated as part of 17.12. |
Good day, When can we expect this fix to be available? Thanks |
@mariusmcalpine The fix is available in VS 17.12 Preview 2.0. |
Description
There is an error shown in VS when in XAML the Content of a DataTemplate is not a View:
The error says "Property DataTemplateContent does not support value of type MyTabViewItem".
Note that MyTabViewItem is not a View, it is a BindableObject:
public class MyTabViewItem : BindableObject { }
Rationale:
In our case, we have a custom TabView. Each TabView-item contains two views - one header view, and one content view. This is one of the reasons we chose for the MyTabViewItem to not be a view, and it has two properties that contain the two views - Header and Content properties.
While we understand that most items-controls will use the DataTemplate with a View in them, this is not necessarily a restriction, as the DataTemplate can create content of type object (for reference see the signature of the CreateContent() method of the DataTemplate -
maui/src/Controls/src/Core/ElementTemplate.cs
Line 73 in f2cc45e
This is why we would like for that error to be removed as users of our custom TabView may think there is an error with their code.
Steps to Reproduce
Expected Behavior: No error should be displayed.
Actual Behavior: The whole DataTemplate is underlined and an error is displayed - "Property DataTemplateContent does not support value of type MyTabViewItem".
Link to public reproduction project repository
https://github.com/telerik/ms-samples/tree/main/Maui/XamlErrorForDataTemplate
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
8.0.7 SR2
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
No response
Did you find any workaround?
I did not find a workaround.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: