应用Toolkit主题时,TabItem内容将不再延伸 [英] TabItem content won't stretch anymore when applying Toolkit theme

查看:69
本文介绍了应用Toolkit主题时,TabItem内容将不再延伸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新发布的Silverlight Toolkit开发Silverlight 4项目。

Hi, I'm working on Silverlight 4 Project using the latest released Silverlight Toolkit.

 一旦我尝试将主题应用到我的usercontrol,布局我的tabcontrol内部搞砸了,可以通过一些示例轻松复制:

 As soon as I try applying a theme to my usercontrol, the layout inside my tabcontrol gets messed up, which can be easily reproduced in a little sample:

 工作布局:(tabitem中的网格占用所有可用空间)

 working layout: (Grid inside the tabitem takes up all available space)

 

 <UserControl x:Class="test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">

    <Grid x:Name="LayoutRoot" Background="White">
        <!--<toolkit:ExpressionLightTheme  Padding="10">-->
            <sdk:TabControl>
                <sdk:TabItem Header="tabItem1" Name="tabItem1" >
                    <Grid Margin="10">
                        <TextBlock Grid.Column="0" Text="Test"  ></TextBlock>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem Header="tabItem2" Name="tabItem2">
                    <Grid />
                </sdk:TabItem>
            </sdk:TabControl>
        <!--</toolkit:ExpressionLightTheme> -->
    </Grid>
</UserControl>


 

 如果您删除主题标记周围的评论,以便使用主题,标签内容将不再延伸,但以tabitem为中心,只占用所需的空间,即使Vertical / Horizo​​ntalAlignment = Stretch应用于
元素。

 

 if you remove the comments around the theme tag, so that the theme gets used, the tab content won't stretch anymore, but gets centered with the tabitem, taking only as much space as required, even if Vertical/HorizontalAlignment=Stretch is applied to the elements.

 感谢任何提示/解决方案如何解决这个问题。 (我对XAML还很新)

 Thanks for any hints/solutions how to get around this. (I'm still pretty new to XAML)

Nina

Nina

推荐答案

 我认为问题在于大多数时候主题附带的样式会将默认的alinement属性从Stretch更改为Top,Left,因此您需要将它们显式设置为Stretch喜欢:

 I think the problem is that the Styles that comes with the themes most of the time change the default alinement's properties from Stretch to Top, Left, so you need to set them explicitly to Stretch like :

  

  

  <toolkit:ExpressionLightTheme  Padding="10">
            <sdk:TabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <sdk:TabItem Header="tabItem1" Name="tabItem1" >
                    <Grid Margin="10">
                        <TextBlock Grid.Column="0" Text="Test"  ></TextBlock>
                    </Grid>
                </sdk:TabItem>
                <sdk:TabItem Header="tabItem2" Name="tabItem2">
                    <Grid />
                </sdk:TabItem>
            </sdk:TabControl>
       </toolkit:ExpressionLightTheme>


 希望这能解决问题。

 Hope this will solve the problem.


这篇关于应用Toolkit主题时,TabItem内容将不再延伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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