2012-04-09 9 views
1

これまで書いたことはありますが、これは動作しません。最初の線分は、(0,0)から(20,20)まで、OKです。左上から右下までの対角線です。しかし、2番目の線分は右上から左下に対角線で描かれていません。Silverlightを使用してクロスサインを作成しようとしています。パス要素

私はこの要素の意味を正しく理解していないと思います。

これを修正する方法を教えてください。

<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

+0

@Phil Myパスは、ボタンの内側にあるグリッド内に含まれています。 – teenup

答えて

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> 
関連する問題