WPF. Basic UI

1, round button (wpf modify the button style rounded, click on the flashing .html [ https://social.msdn.microsoft.com/Forums/zh-CN/612b4ec6-5352-4ae1-9778-6a997848853c/wpf? = wpfzhchs FORUM  ])

 ZC: rounded search to achieve a lot, but the button is pressed bounce effect Dounong no, there is also the effect of pressing the bounce, reservations under:

<Style   TargetType="{x:Type Button}">
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border  x:Name="_border"  CornerRadius="8" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"   SnapsToDevicePixels="true">
                        <ContentPresenter x:Name="_contentPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#ADADAD"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="Blue" TargetName="_border"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Margin" TargetName="_contentPanel" Value="2,2,0,0"/>
                            <Setter Property="Background" Value="Gray" TargetName="_border"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

  ZC: Press the effect is to see that the name "IsPressed" the "Trigger"

2、

3、

4、

5、

Guess you like

Origin www.cnblogs.com/csskill/p/11263616.html