2012-04-09 62 views
1

這是我寫到現在爲止,但這不起作用。第一條線段是OK,從(0,0)到(20,20) - 從左上角到右下角的對角線。但是,第二條線段不是從右上角到左下角的對角線。試圖使用Silverlight Path元素創建一個十字標記

我想,我不知道這個元素的語義是否正確。

請告訴我如何糾正?

<Path Stroke="White" StrokeThickness="3"> 
<Path.Data> 
<GeometryGroup> 
<LineGeometry StartPoint="0,0" EndPoint="20,20" /> 
<LineGeometry StartPoint="20,0" EndPoint="0,20" /> 
</GeometryGroup> 
</Path.Data> 
</Path> 

這是它創造: -

Trying to create cross sign

+0

這對我的作品。你的路徑是什麼? – Phil 2012-04-09 15:50:28

+0

@Phil我的路徑包含在一個Button內的Grid中。 – teenup 2012-04-09 17:22:08

回答

2

把你的路徑視框所以它擴展到按鈕的大小。例如

<Grid> 
    <Button Height="23"> 
     <Viewbox> 
       <Path Stroke="White" StrokeThickness="3"> 
        <Path.Data> 
         <GeometryGroup> 
          <LineGeometry StartPoint="0,0" EndPoint="20,20" /> 
          <LineGeometry StartPoint="20,0" EndPoint="0,20" /> 
         </GeometryGroup> 
        </Path.Data> 
       </Path> 
     </Viewbox> 
    </Button> 
</Grid> 

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Button HorizontalContentAlignment="Left"> 
     <StackPanel Orientation="Horizontal"> 
      <Viewbox> 
       <Path StrokeEndLineCap="Triangle" StrokeStartLineCap="Triangle" 
         Stroke="White" StrokeThickness="3"> 
        <Path.Data> 
         <GeometryGroup> 
          <LineGeometry StartPoint="0,0" EndPoint="20,20" /> 
          <LineGeometry StartPoint="20,0" EndPoint="0,20" /> 
         </GeometryGroup> 
        </Path.Data> 
       </Path> 
      </Viewbox> 

      <TextBlock Margin="5,0,0,0" VerticalAlignment="Center" Text="Press me"/> 
     </StackPanel> 
    </Button> 
</Grid> 
相關問題