简体   繁体   English

在Silverlight中隐藏选项卡标题

[英]Hiding Tab headers in Silverlight

I have tried several ways but I could not manage to do it. 我尝试了几种方法,但我无法做到。 How can I hide the tab headers in tabcontrols in Silverlight . 如何在Silverlight中的tabcontrols中隐藏选项卡标题。 I have searched on the Internet but mostly the solutions are for WPF. 我在互联网上搜索过,但主要是针对WPF的解决方案。

I have buttons to navigate between tabs but I do not want user to see the headers. 我有按钮在标签之间导航,但我不希望用户看到标题。

Thanks. 谢谢。

As Martin suggested, i used microsoft templates to fix the problem. 正如Martin建议的那样,我使用微软模板来解决问题。

Firstly there are good default templates for TabItem and TabControl on this site . 首先,此站点上的TabItem和TabControl有很好的默认模板。 I used them. 我用过它们。

This code is for silverlight 5, and for silvelight 3 or 4, you need to change "sdk". 此代码适用于silverlight 5,对于silvelight 3或4,您需要更改“sdk”。 You need to use like the one in the site that I give. 您需要使用我提供的网站中的那个。

I just took the related part of the template, I am not sure to take all the template and update only this related part. 我刚刚接受了模板的相关部分,我不确定是否采用所有模板并仅更新此相关部分。 However when use like the code below, ie, only related part of the template, it works fine. 但是,当使用类似下面的代码,即只有模板的相关部分时,它工作正常。

<StackPanel Grid.Row ="1" Grid.Column="1" >
<StackPanel.Resources>
    <Style TargetType="sdk:TabControl" x:Key="HeaderTemplate">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="sdk:TabControl">
                    <!--here comes the template-->  
                    <Grid x:Name="TemplateTop" Visibility="Collapsed">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <controlsPrimitives:TabPanel x:Name="TabPanelTop" Margin="2,2,2,-1" Canvas.ZIndex="1" Visibility="Collapsed"/>
                        <Border MinHeight="10" MinWidth="10" Grid.Row="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0,0,3,3">
                            <ContentPresenter x:Name="ContentTop" Cursor="{TemplateBinding Cursor}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalAlignment}"/>
                        </Border>
                        <Border x:Name="DisabledVisualTop" IsHitTestVisible="False" Opacity="0" Grid.Row="1" Grid.RowSpan="2" Canvas.ZIndex="1" Background="#8CFFFFFF" CornerRadius="0,0,3,3"/>
                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</StackPanel.Resources>

<sdk:TabControl Style="{StaticResource HeaderTemplate}">
    <sdk:TabItem>
    </sdk:TabItem>
    <!--your tabes comes here-->  
</sdk:TabControl></StackPanel>

I think you can directly use the part between 我想你可以直接使用之间的部分

<StackPanel.Resources>...</StackPanel.Resources>

I hope it helps the people who have the same problem. 我希望它可以帮助那些有同样问题的人。

There is also a similar problem and answer here . 还有一个类似的问题和答案在这里

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

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