MartinStettner
MartinStettner

Reputation: 29164

Set WPF TabControl to show the same Content for every tab

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?

Upvotes: 9

Views: 9821

Answers (2)

Sonorx
Sonorx

Reputation: 1439

<TabControl>
        <TabControl.ContentTemplate>
            <DataTemplate>
               your view
            </DataTemplate>
        </TabControl.ContentTemplate>
    </TabControl>

Upvotes: 16

MartinStettner
MartinStettner

Reputation: 29164

I found a solution in this question

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

Upvotes: 0

Related Questions