WPF 三态按钮(PNG贴图)。。。。。。。。。。。

    <Window.Resources>
<Style x:Key="ButtonLeft" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <StackPanel Orientation="Horizontal">
                            <Image Name="minBtn" Source="/FingerPrint;component/Resources/BG_btn_normal.png" />
                        </StackPanel>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Source" Value="/FingerPrint;component/Resources/BG_btn_hover.png" TargetName="minBtn" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Source" Value="/FingerPrint;component/Resources/BG_btn_click.png" TargetName="minBtn" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

        <Button   Content="Button" Height="31" HorizontalAlignment="Left" Margin="269,95,0,0" Name="button1" VerticalAlignment="Top" Width="143" Foreground="#FFDE4747" Focusable="True" BorderBrush="{x:Null}" BorderThickness="0" Style="{StaticResource ButtonLeft}">
        </Button>



        <Style x:Key="RadioLeft" TargetType="{x:Type RadioButton}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RadioButton}">
                        <StackPanel Orientation="Horizontal" >
                            <ContentControl Name="BtnFont" VerticalAlignment="Center"  Content="{TemplateBinding Content}"  FontFamily="Microsoft JhengHei" FontWeight="Bold" FontSize="16" Foreground="#7d7d7d" />
                            <Image Stretch="None" VerticalAlignment="Center" Margin="5,0,0,0" Name="BtnBackGround" Source="{x:Null}" />
                        </StackPanel>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="True"/>
                                    <Condition Property ="IsChecked" Value="False" />
                                </MultiTrigger.Conditions>

                                <Setter Property="Foreground" Value="#FFFFFF" TargetName="BtnFont" />

                            </MultiTrigger>

                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsPressed" Value="True"/>
                                    <Condition Property ="IsChecked" Value="False" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Foreground" Value="#7d7d7d" TargetName="BtnFont" />
                            </MultiTrigger>


                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property ="IsChecked" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Source" Value="/FingerPrint;component/Resources/label.png " TargetName="BtnBackGround" />
                                <Setter Property="Foreground" Value=" #7ebdff" TargetName="BtnFont" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>



阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭