2014-04-07 2 views
0

캔버스에 일부 선을 표시하려고합니다.이 선들은 Y 축 위치가 다르므로 itemscontrol을 작성하고 Y 값과 선에 표시 할 텍스트가있는 사전에 바인딩됩니다.목록보기의 행에 대한 참조 점

내 문제는 개별 항목의 원점을 기준으로 (x1, y1) (x2, y2) 점에 선이 표시되지만 각 선이 캔버스 원점에서 Y 축 거리를 가지게하는 것입니다.

<Canvas Margin="0,8,0,8" Height="374" Width="150" > 
<ItemsControl ItemsSource="{Binding Path=YPointsDictionary Margin="0"> 

<ItemsControl.ItemTemplate> 
    <DataTemplate> 
      <StackPanel Orientation="Horizontal"> 
      <Line X1="0" Y1="{Binding Value}" X2="150" Y2="{Binding Value}" 
       StrokeThickness="2" Stroke="Yellow" StrokeDashArray="2,2" /> 
     <Label Content="{Binding Key}" Foreground="Yellow" />     
     </StackPanel> 
    </DataTemplate> 
    </ItemsControl.ItemTemplate> 
    </ItemsControl> 
    </Canvas> 

답변

0

stackPanel Orientation vertical을 지정하면 결과가 나타납니다. 이게 니가 원하는거야?

예 :

내 대답은 이리와 X 각 항목의 Y 원점으로 왼쪽 캔버스와 상단을 결합 할 필요가 발견
<StackPanel Orientation="Vertical" > 
     <Line X1="0" Y1="50" X2="150" Y2="50" Stroke="red" StrokeThickness="5"></Line> 
     <Line X1="0" Y1="100" X2="150" Y2="100" Stroke="Blue" StrokeThickness="5"></Line> 
     <Line X1="0" Y1="150" X2="150" Y2="150" Stroke="green" StrokeThickness="5"></Line> 
    </StackPanel> 
관련 문제