Set WPF TabControl to show the same Content for every tab

╄→гoц情女王★ 提交于 2019-12-06 01:21:02

问题


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?


回答1:


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



回答2:


I found a solution in this question

  • TabControl's TabItems sharing same content... Do Not Want

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



来源:https://stackoverflow.com/questions/5350528/set-wpf-tabcontrol-to-show-the-same-content-for-every-tab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!