2017-11-25 20 views
0

私はツールボックスを持っていて、塗りつめたいと思っています。しかし、私はこれにしないでください。シンプルな問題ですが、私はそれを知っています。WPFドックパネルの幅xamlの伸び

<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="0"> 


      <DockPanel Height="40" HorizontalAlignment="Stretch" Background="#eaeaea" LastChildFill="True"> 

       <StackPanel HorizontalAlignment="Stretch" DockPanel.Dock="Left" Orientation="Vertical"> 

        <Border BorderThickness="1" BorderBrush="#eaeaea" CornerRadius="10" Padding="2" VerticalAlignment="Stretch" > 

         <Grid Width="auto" HorizontalAlignment="Stretch" > 

          <Border Name="mask" Background="#eaeaea" CornerRadius="6,0,0,6" HorizontalAlignment="Stretch" /> 

         <StackPanel Height="30" Margin="2,2,2,2" Name="kucukmenu" HorizontalAlignment="Stretch" Width="auto"> 

           <StackPanel.OpacityMask> 
            <VisualBrush Visual="{Binding ElementName=mask}"/> 
           </StackPanel.OpacityMask> 


          </StackPanel> 

         </Grid> 

        </Border> 

      </StackPanel> 

       <StackPanel Height="40" Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Right"> 
        <Button Style="{DynamicResource systembtn}"> 
         <Image Source="images/icons/settings.png" HorizontalAlignment="Right"/> 
        </Button> 
        <Button Style="{DynamicResource systembtn}"> 
         <Image Source="images/icons/minimize.png" HorizontalAlignment="Right" /> 
        </Button> 
        <Button Style="{DynamicResource systembtn}"> 
         <Image Source="images/icons/cancel.png" HorizontalAlignment="Right"/> 
        </Button> 
       </StackPanel> 
      </DockPanel> 

    </StackPanel> 

Now it looks like this

I want to this

答えて

1

あなたは、単に同じくらいの領域としての項目をすることができ埋め、これはあなたの青い部分のため

Width="Auto"あるGridWidth="*"

ColumnDefinitionsと手段を使用することができますアイテムが必要とするエリアだけを塗りつぶすことを意味しますあなたが行うには、より複雑なものが必要な場合は、このパッケージを使用することができます xaml grid

<Grid Height="40"> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="*" /> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
    </Grid.ColumnDefinitions> 
    <DockPanel Grid.Column="0" Width="100"> 
     <StackPanel HorizontalAlignment="Stretch" DockPanel.Dock="Left" Orientation="Vertical"> 
      <StackPanel.Background> 
       <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
        <LinearGradientBrush.RelativeTransform> 
         <TransformGroup> 
          <ScaleTransform CenterY="0.5" CenterX="0.5" /> 
          <SkewTransform CenterY="0.5" CenterX="0.5" /> 
          <RotateTransform Angle="90" CenterY="0.5" CenterX="0.5" /> 
          <TranslateTransform /> 
         </TransformGroup> 
        </LinearGradientBrush.RelativeTransform> 
        <GradientStop Color="#FFBFC5E2" Offset="0" /> 
        <GradientStop Color="#FF123CF5" Offset="1" /> 
       </LinearGradientBrush> 
      </StackPanel.Background> 
     </StackPanel> 
    </DockPanel> 
    <Button Grid.Column="1" Content="btn 1" /> 
    <Button Grid.Column="2" Content="btn 2" /> 
    <Button Grid.Column="3" Content="btn 3" /> 
</Grid> 

を検索して、ボタン

あなたはより多くの情報を見つけることができるためであるhttps://github.com/sourcechord/GridExtra