2012-04-06 32 views

Respuesta

3

Una opción sencilla es simplemente superponer los controles y luego jugar con márgenes

<Grid> 
     <GroupBox Header="Title" Margin="0,3,0,0" /> 
     <StackPanel Orientation="Horizontal" 
      VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,0,10,0"> 
      <Button Margin="2" Content="Suchen"/> 
      <Button Margin="2" Content="Neu"/> 
     </StackPanel> 
    </Grid> 

Si quieres un estilo reutilizable, entonces tendría que extraer plantilla de control de la GroupBox y modificar eso. Algo así como

<Page.Resources> 
    <BorderGapMaskConverter x:Key="BorderGapMaskConverter"/> 
    <Style x:Key="GroupBoxStyle1" TargetType="{x:Type GroupBox}"> 
     <Setter Property="BorderBrush" Value="#D5DFE5"/> 
     <Setter Property="BorderThickness" Value="1"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="{x:Type GroupBox}"> 
        <Grid SnapsToDevicePixels="true"> 
         <Grid.ColumnDefinitions> 
          <ColumnDefinition Width="6"/> 
          <ColumnDefinition Width="Auto"/> 
          <ColumnDefinition Width="*"/> 
          <ColumnDefinition Width="6"/> 
         </Grid.ColumnDefinitions> 
         <Grid.RowDefinitions> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="Auto"/> 
          <RowDefinition Height="*"/> 
          <RowDefinition Height="6"/> 
         </Grid.RowDefinitions> 
         <Border BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="4" Grid.Column="0" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3"/> 
         <Border x:Name="Header" Grid.Column="1" Padding="3,1,3,0" Grid.Row="0" Grid.RowSpan="2"> 
          <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 
         </Border> 
         <ContentPresenter Grid.ColumnSpan="2" Grid.Column="1" Margin="{TemplateBinding Padding}" Grid.Row="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> 
         <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="4" CornerRadius="4" Grid.Row="1" Grid.RowSpan="3"> 
          <Border.OpacityMask> 
           <MultiBinding ConverterParameter="7" Converter="{StaticResource BorderGapMaskConverter}"> 
            <Binding ElementName="Header" Path="ActualWidth"/> 
            <Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}"/> 
            <Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}"/> 
           </MultiBinding> 
          </Border.OpacityMask> 
          <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3"> 
           <Border BorderBrush="White" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> 
          </Border> 
         </Border> 
         <StackPanel Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="0" Grid.RowSpan="3" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" > 
          <Button Margin="2" Content="Suchen"/> 
          <Button Margin="2" Content="Neu"/> 
         </StackPanel> 
        </Grid> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
</Page.Resources> 

<Grid> 
    <Grid> 
     <GroupBox Header="Title" Style="{StaticResource GroupBoxStyle1}"></GroupBox> 
    </Grid> 
</Grid> 
Cuestiones relacionadas