TabControl - UserControls inside DataTemplates are not rendered
See original GitHub issueWhen using DataTemplates in a TabControl, if the DataTemplate contains a UserControl, the UserControl won’t be displayed.
Example
<TabControl>
<TabControl.DataTemplates>
<DataTemplate DataType="vms:SampleViewModel">
<StackPanel Orientation="Vertical">
<TextBlock Text="SampleViewModel.."/>
<local:SampleView />
</StackPanel>
</DataTemplate>
</TabControl.DataTemplates>
<TabItem Header="Tab 1 - Content from DataTemplate"><vms:SampleViewModel /></TabItem>
<TabItem Header="Tab 2" Content="Content for item 2"/>
<TabItem Header="Tab 3 - View without DataTemplate"><local:SampleView /> </TabItem>
</TabControl>
When I select Tab 1, it shows me my DataTemplate but any UserControl (local:SampleView) inside the DataTemplate is not displayed, it only shows the TextBlock If I select Tab 3, the UserControl (local:SampleView) is shown properly…
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
My UserControl isn't being rendered when used inside a ...
But if I try to use the UserControl in a DataTemplate it doesn't work. For example, if I have a DataTemplate like
Read more >[Latest] NoesisGUI v3.2.1 - Page 2 - Forums
Fixed: TabControl content layout was not deterministic. Fixed: DataTemplate were not found when stored by type in a ResourceDictionary.
Read more >Problem with TabControl Template and Binding in WPF.
I would like to put image in TabControl header using binding, but below code doesn't work. I would like to know why, and...
Read more >MapView in ContentPresenter bug?
I was trying to display multiple viewmodels where the DataTemplate contains a MapView in an itemscontrol (TabControl), I discovered that the map ...
Read more >How to use a Tab Control and Tab Items with MVVM in C# ...
Learn how to use a Tab Control and its corresponding tab items when using the MVVM pattern in C#. This tutorial will show...
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
@braca In
ContentPresenter.cs:249
replaceif (newChild.Parent == null && TemplatedParent == null)
toif (newChild.Parent == null)
It will help though side effects are not clear yet.@Gillibald yeah it’s really not obvious. I think there might be a better way…
Should be fixed by https://github.com/AvaloniaUI/Avalonia/pull/2218 btw.