테두리 컨트롤 안에 확장기 컨트롤이 있습니다. 확장기가 접힐 때 테두리는 동일한 높이를 유지합니다. 테두리 높이를 높이려면 어떻게해야합니까? 이 문제를 illustates 코드 :확장기 축소시 상위 컨테이너가 축소되지 않음
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="Red"/>
<Setter Property="BorderThickness" Value="2" />
</Style>
<Style TargetType="StackPanel" x:Key="StackPanel1">
<Setter Property="Orientation" Value="Vertical"/>
<Setter Property="MaxHeight" Value="100" />
</Style>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="panelBackgroundBrush">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFE3EFFF" Offset="0" />
<GradientStop Color="#FFAFD2FF" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<Style TargetType="{x:Type GridSplitter}">
<Setter Property="FrameworkElement.Height" Value="3"/>
<Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
<Setter Property="UIElement.Focusable" Value="False" />
<Setter Property="FrameworkElement.Cursor" Value="SizeNS"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border>
<Border BorderThickness="0" BorderBrush="{StaticResource panelBackgroundBrush}">
<Canvas Width="19" Height="3">
<Canvas.Resources>
<Style TargetType="Rectangle">
<Setter Property="Width" Value="2" />
<Setter Property="Height" Value="2" />
<Setter Property="Canvas.Top" Value="0" />
</Style>
</Canvas.Resources>
<Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="1" />
<Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="5" />
<Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="9" />
<Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="13" />
<Rectangle Fill="{StaticResource panelBackgroundBrush}" Canvas.Left="17" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="0" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="4" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="8" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="12" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Canvas.Left="16" />
</Canvas>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Border>
<Expander>
<Border>
<StackPanel Style="{StaticResource ResourceKey=StackPanel1}" >
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
</StackPanel>
</Border>
</Expander>
</Border>
<Border Grid.Row="1">
<Expander>
<Border>
<StackPanel Style="{StaticResource ResourceKey=StackPanel1}" >
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
</StackPanel>
</Border>
</Expander>
</Border>
<GridSplitter Grid.Row="1" />
<Border Grid.Row="2">
<Expander>
<Border>
<StackPanel Style="{StaticResource ResourceKey=StackPanel1}" >
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
<TextBlock Text="aaaa"/>
</StackPanel>
</Border>
</Expander>
</Border>
<GridSplitter Grid.Row="2" />
</Grid>
Expander 내부에 테두리가 생기지 않는 이유는 무엇입니까? – code4life
@ code4life 왜냐하면 Expander 내용 만 포함하기 때문에 Expander 자체는 포함하지 않기 때문입니다. –
Height 또는 margin 속성을 고정하지 않으면 테두리가 실제 높이를 변경해야합니다. –