0

皆さん、私はWPFに非常に慣れていないので、Samの電子書籍で学習を始めました。私はちょうど次のように本で与えられた同じコードを試しました

<Window x:Class="wpfTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">

    <Button Background="Black">
        <Button.Content>
            <Ellipse Width="103" Height="107" Fill="Yellow" />
        </Button.Content>
    </Button>
</Window>

残念なことに、ボタンを1回クリックすると、ゆっくりと点滅し始め、指定どおりに黒の背景と白/青の背景が表示され、停止することはありません。エフェクト/スタイル/トリガー/アニメーションについては触れていないので、デフォルトの動作がそのようなものである理由はわかりません。:(誰かが私を導き、それを修正することができますか?私にも同じ理由を理解させてください:(

4

1 に答える 1

0
<Window x:Class="testwpf.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <Style x:Key="BorderlessButton" TargetType="{x:Type Button}">
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Name="border" Background="{TemplateBinding Background}">
                        <ContentPresenter Name="content" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  Margin="{TemplateBinding Padding}"
                                  RecognizesAccessKey="True"
                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <Button Style="{DynamicResource BorderlessButton}">
        <Button.Content>
            <Ellipse Width="103" Height="107" Fill="Yellow" />
        </Button.Content>
    </Button>
</Grid>

カスタムスタイルは、システムアニメーションアニメーションを無効にします。ここからのコード

于 2012-08-07T08:38:48.063 に答える