I have a TabControl that is bound to a collection of Viewmodels, which get translated into an appropriate to be drawn into the tab:
<Window.Resources>
<ResourceDictionary>
<DataTemplate DataType="{x:Type charting:LineFormatViewModel}">
<charting:LineFormatView />
</DataTemplate>
<DataTemplate DataType="{x:Type charting:IndexSettingsViewModel}">
<charting:IndexSettingsView />
</DataTemplate>
....
</ResourceDictionary>
</Window.Resources>
<TabControl ItemSource="Binding ViewModels" />
I've been trying to find a way to always draw the TabControl at the maximum width and height of any of it's children. Let WPF Tabcontrol height assume height of largest item? mentions a couple of ways to achieve this in the answers (from what I udnerstood):
- using Grid with SharedSizeGroup - seems to need to be applied to a DataTemplate on the actual content of the TabControl, which overwrites the automated View drawing achieveing by the VM->View mapping created in the resourcedictionary
- Using a width/height converter, which would require my TabControl to be bound to a collection of UI elements instead of viewmodels
Does anyone have any experience solving a similar issue? I seem to be hitting more walls every time I make some progress on this.