Adding a TabViewItem derived class to TabView crashes the application
See original GitHub issueDescribe the bug
If I add a class derived from TabViewItem
to TabView, it crashed the application with
ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32)
System.Exception: No installed components were detected. ListViewItemPresenter can only be used as the first child in the template for a ListViewItem.
StackTrace from AppCenter
System.Runtime.InteropServices
McgMarshal.ThrowOnExternalCallFailed (Int32 hr, RuntimeTypeHandle typeHnd) f:\dd\ndp\fxcore\CoreRT\src\System.Private.Interop\src\Shared\McgMarshal.cs at 1189:13
__Interop
ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32)
__Interop
ForwardComStubs.Stub_12[TThis] (__ComObject, Int32)
Microsoft.AppCenter.Utils
ApplicationLifecycleHelper.<ctor>b__17_1 (Object, UnhandledErrorDetectedEventArgs)
Steps to reproduce the bug
Steps to reproduce the behavior:
- Use following code to add
public class TabularItem : TabViewItem
{
public TabularItem()
{
}
}
private void AddTabItem(TabView tabView)
{
var newTab = new TabularItem();
// The Content of a TabViewItem is often a frame which hosts a page.
var frame = new Frame();
newTab.Content = frame;
frame.Navigate(typeof(OptionPage));
tabView.TabItems.Add(newTab);
}
Expected behavior
Screenshots
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.4.0
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) | |
April 2018 Update (17134) | Yes |
Fall Creators Update (16299) | |
Creators Update (15063) |
Device form factor | Saw the problem? |
---|---|
Desktop | Yes |
Mobile | |
Xbox | |
Surface Hub | |
IoT |
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to avoid app crash with TabView inside ...
I'm using a TabView inside NavigationView but my app crashes when I try to navigate backwards, it shows this error message "Thread 1: ......
Read more >iOS 15 More Tab Crash | Apple Developer Forums
The app I'm working on crashes by trying to reference a deallocated object. The object is a subclass of UITabBarController, and this crash...
Read more >Android, crashes when nested inside a tabview
Hi John, This error isn't specifically related to UI for Xamarin, but rather because you're attempting to add an element that already exists....
Read more >Xamarin forms templatedview. I'm trying to do a content button ...
Xamarin forms templatedview. I'm trying to do a content button with only shared code (no native project code, so no renderer and no...
Read more >Windows Community Toolkit | XAML Brewer, by Diederik Krols
Here's how our sample app looks like: It covers: programmatical TabViewItem creation,; creating a reusable 'TabsWindow' control,; drag-and-drop ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ranjeshj I just tested it, the fix works.
Try adding the Bindable attribute on the custom type. In debug builds the metadata is obtained through reflection but in release builds it is code gen which causes issues like this one. This issue documents a couple of differences between debug and release builds.