none
江湖救急,请教TabControl的标签页调整问题 RRS feed

  • 问题

  • 问题:
         WPF里面如何调整“TabControl”标签页的大小?     默认的太小了,不好触摸啊?


    Science and technology is my lover.

    2013年9月9日 7:05

答案

  • 我们可以通过设置TabControlTabItem的样式来修改TabItem的大小。下面是一段示例代码,

    <Window x:Class="WpfTabItemSize.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Window.Resources>
            <Style  TargetType="{x:Type TabItem}">
                <Setter Property="Width" Value="150"/>
            </Style>
        </Window.Resources>
        <Grid>
            <TabControl>
                <TabItem >
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock>概况</TextBlock>
                        </StackPanel>
                    </TabItem.Header>
                </TabItem>
                <TabItem >
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock>用电</TextBlock>
                        </StackPanel>
                    </TabItem.Header>
                </TabItem>
                <TabItem >
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock>用水</TextBlock>
                        </StackPanel>
                    </TabItem.Header>
                </TabItem>
            </TabControl>
        </Grid>
    </Window>

    谢谢!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年9月10日 2:45
    版主