开发者

How to set the default style for tabitem in a tabcontrol's style

开发者 https://www.devze.com 2023-02-04 23:06 出处:网络
I\'m creating a specific style for some TabControl in my application. <开发者_JS百科;TabControl Style=\"{StaticResource MyTabControl}\">

I'm creating a specific style for some TabControl in my application.

<开发者_JS百科;TabControl Style="{StaticResource MyTabControl}">
</TabControl>

I want to also style TabItem in the case of this specific TabControl's Style.

For now, I must write :

<TabControl Style="{StaticResource MyTabControl}">
    <TabItem Style="{StaticResource MyTabItem}" Header="First" />
    <TabItem Style="{StaticResource MyTabItem}" Header="Second" />
</TabControl>

Instead of having to specify the "MyTabItem" style on each TabItem, is there any way to set the default TabItem style only in the scope of a specific TabControl Style ?

I didn't found a way to specify, in the style of my TabControl, which style should be applied on all children TabItems.


<TabControl ItemContainerStyle="{StaticResource MyTabItem}"/>


put style for target type TabItem as a implicit style under your MyTabItem style resource

<Style TargetType="TabControl" x:Key="TabControlStyle">
            <Style.Resources>
                <Style TargetType="TabItem">

                </Style>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号