简体   繁体   English

UserControl作为TabItem

[英]UserControl as a TabItem

I've been playing with WPF and I'm not sure what I'm trying to do is possible. 我一直在玩WPF,我不确定我想做什么是可能的。 So is it possible to have a usercontrol describing a tabitem? 那么有可能让用户控件描述一个tabitem吗? I've tried but without success. 我试过但没有成功。

Right now I use user controls for the content but I would like to change that to be more generic. 现在我对内容使用用户控件,但我想将其更改为更通用。

You can: 您可以:

1) Place a UserControl inside a TabItem : 1)将UserControl放在TabItem

<TabControl>
    <TabItem>
        <local:MyUserControl/>
    </TabItem>
</TabControl>

2) Inherit from TabItem rather than UserControl : 2)继承自TabItem而不是UserControl

public class MyTabItem : TabItem { ... }

<TabControl>
    <local:MyTabItem/>
</TabControl>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM