潜移默化学会WPF(样式篇)---改造CheckBox,全新metro风格

        <Style TargetType="CheckBox">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="CheckBox">
                        <StackPanel Orientation="Horizontal">
                            <Grid Height="20" Width="20">
                                <Image x:Name="imageNoChecked" Source="/MPCR.GE.Client.EmployeeManagement;component/Images/ckNoChecked.png" Height="32" Width="32"  Margin="-12" />
                                <Image x:Name="imageChecked" Source="/MPCR.GE.Client.EmployeeManagement;component/Images/ckChecked.png" Height="32" Width="32" Margin="-12" />
                            </Grid>
                            <Label Content="{TemplateBinding Content}" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" />
                        </StackPanel>

                        <ControlTemplate.Triggers >
                            <Trigger Property="IsChecked" Value="True">
                                <Setter TargetName="imageChecked" Property="Visibility" Value="Visible" />
                                <Setter TargetName="imageNoChecked" Property="Visibility" Value="Hidden" />
                            </Trigger>
                            <Trigger Property="IsChecked" Value="False">
                                <Setter TargetName="imageChecked" Property="Visibility" Value="Hidden" />
                                <Setter TargetName="imageNoChecked" Property="Visibility" Value="Visible" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

把图片地址换一下就行了,一个上为选中的样子,一张是选中后的图片

我先给你看看我的图片吧

我就这两张图片,回去试试吧,用法你懂的,不懂得Q我,QQ875556003

posted @ 2012-04-19 09:27  AYUI框架  阅读(4106)  评论(2编辑  收藏  举报