0

基本的に、横向きの三角形のボタンがあります(「再生」ボタン用)。xaml デザイン エディターでは、ボタンが三角形として正しく表示されます。ただし、アプリケーションを実行すると、標準の当たり障りのない Windows ボタンとして表示されます。スタイルは次のとおりです。

    <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <ed:RegularPolygon x:Name="PlayerPlay" Fill="#FF080808" InnerRadius="1" PointCount="3" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Stroke="Black">
                            <ed:RegularPolygon.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform Angle="90.635"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </ed:RegularPolygon.RenderTransform>
                        </ed:RegularPolygon>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True"/>
                        <Trigger Property="IsDefaulted" Value="True"/>
                        <Trigger Property="IsMouseOver" Value="True"/>
                        <Trigger Property="IsPressed" Value="True"/>
                        <Trigger Property="IsEnabled" Value="False"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

ボタンは次のとおりです。

<Button x:Name="PlayerPlay" Click="PlayerPlay_Click_1"  Content="" Margin="63.54,4.752,59.686,6.682" Style="{DynamicResource ButtonStyle1}"/>

何がうまくいかないのですか?

ありがとう!

4

1 に答える 1

1

スタイルはどこで作成しましたか? ex Windows Resources 、 Dictionary など

スタイルがボタンがあるリソースにある場合は、StaticResource を使用します。辞書を使用する場合は、App.xaml ファイル ex で宣言していることを確認してください。

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="file_name.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

次に、DynamicResource を使用してスタイルを適用できます。

于 2013-05-12T10:43:08.467 に答える