0

私はスタイルのためにこのコードを持っています

<Window.Resources>
    <Style  x:Key="Mystyle" TargetType="Button">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid >
                        <Polygon Name="poly"  Points="0,0 0,100 50,200"
                         Fill=" TemplateBinding Background}"                            
                        <ContentPresenter HorizontalAlignment="Center"
                                      VerticalAlignment="Center"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</Window.Resources>
<Grid>
    <Button Name="b1" Style="{StaticResource Mystyle }"></Button>

</Grid>

いくつかの計算に基づいて、静的ではなく動的なスタイルタグでポリゴンのポイントを設定する必要があります。ポイントをポリゴンにバインドするにはどうすればよいですか。例私はこれを持っています

PointCollection pc=this.CalculatePolygonPoints(new Point(0,0), 100,Orientation.Flat);

このPCをポリゴンダイナミックにバインドするにはどうすればよいですか?

4

1 に答える 1

2

(タイプ PointCollection の) 新しい依存関係プロパティを作成し、Polygon の Points プロパティをそれに対してバインドしないのはなぜですか? 次に、必要に応じて計算を行います (@code-behind)。UI は自動的に理解します。

これが例です(ObservableCollectionを使用); http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/1293d4cb-87b3-4cdc-97e3-ae2f41caf2d4/

于 2012-07-22T15:22:37.993 に答える