XAML error is shown when the content of a DataTemplate is not a View #22485
Labels
area-tooling
XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging
partner
Issue or Request from a partner team
platform/android 🤖
platform/iOS 🍎
platform/macOS 🍏
macOS / Mac Catalyst
platform/windows 🪟
s/triaged
Issue has been reviewed
s/verified
Verified / Reproducible Issue ready for Engineering Triage
t/bug
Something isn't working
Milestone
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: