0

回転させたいボタンと形状(六角形)があります。しかし、背景を回転させたくありません。回転した六角形のボタンに画像を配置するには? ここに私のコードがあります:

<Button Height="182" Width="155" RenderTransformOrigin="0.5,1.368">
    <Button.Background>
        <ImageBrush ImageSource="mob.png"/>
    </Button.Background>
    <Button.RenderTransform>
        <TransformGroup>
            <ScaleTransform/>
            <SkewTransform/>
            <RotateTransform Angle="270"/>
            <TranslateTransform X="187.488" Y="-187.488"/>
        </TransformGroup>
    </Button.RenderTransform>

    <Button.Template>
        <ControlTemplate>
              <ed:RegularPolygon Fill="{TemplateBinding Background}"/>
          </ControlTemplate>
     </Button.Template>
 </Button>
4

2 に答える 2

0

RenderTransform塗りつぶされたポリゴン全体が回転するため、ボタンの でこれを行うことはできません。の代わりに、ポリラインを含むジオメトリで をed:RegularPolygon使用できます。たとえば、 :PathPathGeometry

<Button Height="182" Width="155">
    <Button.Background>
        <ImageBrush ImageSource="mob.png"/>
    </Button.Background>

    <Button.Template>
        <ControlTemplate>
            <Path Fill="{TemplateBinding Background}">
                <Path.Data>
                    <PathGeometry>
                        <PathGeometry.Transform>
                            ... put transform here ...
                        </PathGeometry.Transform>
                        <PathGeometry.Figures>
                            ... put polyline data here ...
                        </PathGeometry.Figures>
                    </PathGeometry>
                </Path.Data>
            </Path>
        </ControlTemplate>
    </Button.Template>
</Button>
于 2013-04-16T17:20:05.820 に答える