您会为Silverlight推荐哪种GroupBox控件?

时间:2010-07-12 22:43:09

标签: silverlight

似乎每个人都有自己的Silverlight GroupBox控件。你会推荐哪一个。

2 个答案:

答案 0 :(得分:4)

您可以坚持使用Silverlight Toolkit中的常规HeaderedContentControl并将其样式设置为组框:

GroupBox

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:s="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
                    xmlns:t="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit">
    <Style x:Key="GroupBox" TargetType="t:HeaderedContentControl">
        <Setter Property="BorderBrush" Value="LightGray" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="White" />
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="4" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="t:HeaderedContentControl">
                    <Grid Background="{TemplateBinding Background}">                                
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="4"
                                Margin="0,8,0,0" 
                                Grid.RowSpan="2"  />
                        <s:Label Background="{TemplateBinding Background}"
                                 Content="{TemplateBinding Header}" 
                                 ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                 HorizontalAlignment="Left" 
                                 Margin="8,0,0,0" 
                                 Grid.Row="0" />
                        <ContentPresenter Content="{TemplateBinding Content}" 
                                          ContentTemplate="{TemplateBinding ContentTemplate}" 
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                                          Margin="{TemplateBinding Padding}" 
                                          Grid.Row="1" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

答案 1 :(得分:1)

您好我正在使用Contrib Silvelight ...控制功能非常好并且有免费的。

该网站是:http://silverlightcontrib.codeplex.com/

您只需下载二进制库Binaries - Silverlight Contrib 2010.1.0并在您的silverlight项目中添加dll作为参考。