2012-02-08 4 views
2

다각형 높이를 스택 패널의 높이에 바인딩하는 방법을 생각할 수 없습니다. 나는 사각형을 추가하고 싶다면다각형의 높이를 StackPanel 높이로 바인딩

, 내가해야 할 일을했을 모두가 같은 것입니다 :

     <Rectangle Width="75" > 
         <Rectangle.Fill> 
          <SolidColorBrush Color="Red" /> 
         </Rectangle.Fill> 
        </Rectangle> 

이 하나하지 않습니다 브레이크 패널의 높이입니다. 하지만 폴리곤을 사용하면 포인트 중 일부를 비워 둘 수 없으므로 상위 패널과 함께 확장됩니다.

enter image description here

감사

답변

1

<Viewbox>로 다각형을 감 쌉니다.

Viewbox은 자동으로 크기를 조정합니다. 정확히 어떻게 작동합니까? StretchStretchDirection 속성으로 조정할 수 있습니다.

+0

로스, 나는 그 작업을 수행하는 방법 이해가 안 무서워 해요 답장을 보내 주셔서 감사합니다 작동합니다. MSDN에서 Polygon 샘플을 가져 와서 StretchDirection = "UpOnly"인 ViewBox로 왜곡했습니다. 폴리곤은 여전히 ​​상위 스택 패널의 높이 크기를 제동합니다. 구현의 샘플 코드를 제공해 주시면 매우 감사하겠습니다. 감사합니다. . –

+0

네가 말했듯이, 알겠습니다. 감사합니다. –

1

이 솔루션은 너무

enter image description here

<Grid> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="Auto" /> 
    </Grid.RowDefinitions> 
    <StackPanel Orientation="Horizontal"> 
    <Border BorderBrush="Black" BorderThickness="1,1,0,1"> 
     <StackPanel Orientation="Horizontal"> 
     <TextBlock Text="TextBlock1" Margin="2" /> 
     <TextBlock Text="TextBlock2" Margin="2" /> 
     <TextBlock Text="TextBlock3" Margin="2" /> 
     <TextBlock Text="TextBlock4" Margin="2" /> 
     <TextBlock Text="TextBlock5" Margin="2" /> 
     </StackPanel> 
    </Border> 
    <Path Fill="Yellow" Stroke="Black" StrokeThickness="1" 
    Width="50" Stretch="Fill"> 
     <Path.Data> 
     <PathGeometry> 
      <PathFigure IsClosed="True" StartPoint="1,0.5"> 
      <LineSegment Point="0,0" IsSmoothJoin="True" /> 
      <LineSegment Point="0,1" IsSmoothJoin="True" /> 
      </PathFigure> 
     </PathGeometry> 
     </Path.Data> 
    </Path> 
    </StackPanel> 
</Grid> 
+0

그게 바로 내가 찾고 있던 것입니다. 정말 고마워요. 그러나 나는 로스에게 V를 줄 것이다. 왜냐하면 그는 이미 대답했고 명성이 덜했기 때문이다. –

+0

@Esh 아니오 prob :-) – punker76

관련 문제