WPF的TabItem内容对齐方式总是为中心 [英] WPF TabItem Content alignment is always centered

查看:617
本文介绍了WPF的TabItem内容对齐方式总是为中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一些内容我的TabItem里面,但我不能添加一个容器,填充的TabItem的空间。凡是我加入演出了居中。

I'm trying to put some content inside my TabItem, but I can't add a container that fills the space of the TabItem. Anything that I add shows up centered.

我使用从WPF工具包一个主题( WhistlerBlue.xaml 的),所以我想,也许这是什么原因造成了我这个问题。

I'm using a Theme from WPF Toolkit (WhistlerBlue.xaml), so I think that maybe it's that what is causing me this issue.

我无法删除的主题,因为我需要它。最多我可以改变的东西在里面,但我新的WPF,不知道是什么,我应该改变。

I cannot remove the Theme, because I need it. At most I could change something in it, but I'm new to WPF, and don't know what should I be changing.

我的TabControl看起来是这样的:

My TabControl looks like this:

<TabControl Margin="0,71.25,0,206.25" Name="tabControl1" TabStripPlacement="Left">
    <TabItem Name="tabItem1" FlowDirection="LeftToRight" FontSize="22" Height="200" Width="60" >
        <TabItem.Header>
            <StackPanel Orientation="Horizontal" >
                <Image Height="40" Width="40" Margin="20,0,0,0" VerticalAlignment="Center"></Image>
                <TextBlock Margin="15,0,25,0" VerticalAlignment="Center" FontWeight="Bold">
                    Header
                </TextBlock>
            </StackPanel>
        </TabItem.Header>
        <TabItem.Content>
            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,0,0" >
                <TextBlock>Test</TextBlock>
            </StackPanel>
        </TabItem.Content>
    </TabItem>
</TabControl>

有类似的问题,但它不会有答案:<一href="http://stackoverflow.com/questions/819520/in-wpf-how-do-i-get-the-content-of-a-tabitem-to-fill-available-space">In WPF中,我怎么得到的TabItem的内容来填充可用空间?

有人能帮助我吗? 谢谢你。

Can someone help me? Thanks.

推荐答案

好吧,我找到了答案。

主题的的的.xaml 的开始与这些设置TabItem的:

The .xaml of the theme started with these settings for TabItem:

<Style d:IsControlPart="True" TargetType="{x:Type TabItem}">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>

我已经改变了的中心拉伸,然后问题就解决了​​。

I've changed Center to Stretch, and the problem was solved.

我真的需要从书中学习WPF,而不是仅仅尝试的事情了。

I really need to learn WPF from a book, instead of just trying things out.

这篇关于WPF的TabItem内容对齐方式总是为中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆