2017-11-25 22 views
0

나는 도구 상자가있어서 채우기를 원합니다. 그러나 나는 이것을 만들지 않는다. 단순한 문제이지만, 나는 매우 열심히 노력했기 때문에 그것을 안다. 당신은 단순히 ColumnDefinitionsWPF Dockpanel 너비 xaml에서 늘이기

Width="*" 수단 Grid을 사용할 수 있습니다

<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" 이 항목이 필요한 영역 만 채우는 것을 의미합니다. 당신이 할 수있는 더 복잡한 일을해야하는 경우,이 패키지를 사용할 수 있습니다 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