9

I'd like to use a TabControl where each tab shows the same view just with different parameters. Therefore I do not want to create a new content control for each tab but reuse the same control for all tabs (binding some properties of it to the SelectedItem property of the TabControl)

I tried to my contained control as resource and set the Content property of the tab items to it, but this resulted in an exception, because the same element cannot appear as content in to different parents.

Any ideas?

MartinStettner
  • 28,719
  • 15
  • 79
  • 106
  • One possibility is to create a TabControl only with tabs, no content. And create a separate control positioned under the tab control, with your content, and change the parameters based on the selected tab – Jogy Mar 18 '11 at 10:31
  • 1
    I thought of that solution too, but you get a different visual style since the tab control also draws a border around it's content. – MartinStettner Mar 18 '11 at 12:11

2 Answers2

15
<TabControl>
        <TabControl.ContentTemplate>
            <DataTemplate>
               your view
            </DataTemplate>
        </TabControl.ContentTemplate>
    </TabControl>
Sonorx
  • 1,379
  • 10
  • 17
0

I found a solution in this question

(even if the poster wanted specifically the opposite behaviour :) ...)

Community
  • 1
  • 1
MartinStettner
  • 28,719
  • 15
  • 79
  • 106