2010-07-12 29 views

回答

4

你可以只堅持從Silverlight工具包和風格定期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> 
+0

這對我來說足夠接近。但爲什麼他們不使用正常的名稱來進行這種控制呢? – 2010-07-12 23:38:49

+0

我猜他們很醜,Silverlight想要重新開始。 :)雖然WPF有一個GroupBox。 – Josh 2010-07-13 05:40:26

+0

在設計風格之前,它就像醜陋一樣。 – 2010-07-13 07:54:31

相關問題