潜移默化学会WPF(绚丽篇)--热烈欢迎RadioButton,改造成功,改造成ImageButton,新版导航

简介: 原文:潜移默化学会WPF(绚丽篇)--热烈欢迎RadioButton,改造成功,改造成ImageButton,新版导航本样式 含有  触发器 和 动画    模板  ,多条件触发器,还有布局   本人博客园地址  http://www.
原文: 潜移默化学会WPF(绚丽篇)--热烈欢迎RadioButton,改造成功,改造成ImageButton,新版导航

本样式 含有  触发器 和 动画    模板  ,多条件触发器,还有布局

 

本人博客园地址  http://www.cnblogs.com/Fresh-Air/

前台样式 ,我精心设计的

        <Style x:Key="RDOButton" TargetType="{x:Type RadioButton}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RadioButton}">
                        <ControlTemplate.Resources>
                            <Storyboard x:Key="Storyboard1">
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="bd">
                                    <EasingColorKeyFrame KeyTime="0" Value="White"/>
                                    <EasingColorKeyFrame KeyTime="0:0:0.3" Value="#FFAFAFAF"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="Storyboard2">
                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="bd">
                                    <EasingColorKeyFrame KeyTime="0" Value="#FFAFAFAF"/>
                                    <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#D3D3D3"/>
                                </ColorAnimationUsingKeyFrames>
                            </Storyboard>
                        </ControlTemplate.Resources>
                        <BulletDecorator Background="Transparent">
                            <Border x:Name="bd"  HorizontalAlignment="Center" Background="White" CornerRadius="5">
                                <Border.OpacityMask>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="Black" Offset="0"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.OpacityMask>
                                <ContentPresenter Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                        </BulletDecorator>
                        <ControlTemplate.Triggers>

                            <Trigger Property="IsEnabled" Value="false">
                                <Setter TargetName="bd" Property="Background" Value="gray" />
                            </Trigger>
                            <Trigger Property="IsChecked" Value="false">
                                <Setter TargetName="bd" Property="Background" Value="{x:Null}" />
                            </Trigger>
                            <Trigger Property="IsChecked" Value="true">
                                <Trigger.EnterActions>
                                    <BeginStoryboard x:Name="Storyboard2_BeginStoryboard" Storyboard="{StaticResource Storyboard2}"/>
                                </Trigger.EnterActions>
                                <Setter TargetName="bd" Property="Background" Value="#FF606060" />
                            </Trigger>

                            <MultiTrigger>
                                <MultiTrigger.EnterActions>
                                    <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
                                </MultiTrigger.EnterActions>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="True"/>
                                    <Condition Property="IsChecked" Value="False"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="bd" Property="Background" Value="Red" />
                            </MultiTrigger>


                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

 

 

调用,例如

如下:特帅

单用就是radiobutton

 <RadioButton Width="80" Height="70" Margin="2,5" Cursor="Hand" Name="yingyetingToolBarButton" VerticalAlignment="Top" Click="YingyetingToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/yingyeting.png"/>
                        <TextBlock><Run Text="营业厅"/></TextBlock>
                    </StackPanel>
                </RadioButton>

 

这样就是一个toolbar了,自定义的

  <StackPanel Height="80" Orientation="Horizontal" Focusable="True">
                <StackPanel.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF727272" Offset="1" />
                        <GradientStop Color="#FFFFFF" Offset="0.654" />
                        <GradientStop Color="#FEFEFE" Offset="0" />
                        <GradientStop Color="#FFFFFFFB" Offset="0.994" />
                    </LinearGradientBrush>
                </StackPanel.Background>

                <RadioButton Width="80" Height="70" Margin="2,5" Cursor="Hand" Name="yingyetingToolBarButton" VerticalAlignment="Top" Click="YingyetingToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/yingyeting.png"/>
                        <TextBlock><Run Text="营业厅"/></TextBlock>
                    </StackPanel>
                </RadioButton>


                <RadioButton Width="80" Height="70" Margin="2,5"  Cursor="Hand" Name="yingyechaxunToolBarButton" VerticalAlignment="Top" Click="YingyetingToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/yingyechaxun.png"/>
                        <TextBlock><Run Text="营业查询"/></TextBlock>
                    </StackPanel>
                </RadioButton>

                <RadioButton Width="80" Height="70" Margin="2,5" Cursor="Hand" Name="jiaojiebanToolBarButton" VerticalAlignment="Top" Click="JiaojiebanToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/jiaojieban.png"/>
                        <TextBlock><Run Text="交接班"/></TextBlock>
                    </StackPanel>
                </RadioButton>

                <RadioButton Width="80" Height="70" Cursor="Hand" Margin="2,5"  Name="caipinshezhiToolBarButton" VerticalAlignment="Top" Click="CaipinshezhiToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/caipinshezhi.png"/>
                        <TextBlock><Run Text="菜品设置"/></TextBlock>
                    </StackPanel>
                </RadioButton>


                <RadioButton Width="80" Height="70" Cursor="Hand" Margin="2,5"  Name="tingshishezhiToolBarButton"  VerticalAlignment="Top" Click="TingshishezhiToolBarButton_Click"  Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/tingshishezhi.png"/>
                        <TextBlock><Run Text="厅室设置"/></TextBlock>
                    </StackPanel>
                </RadioButton>

                <RadioButton Width="80" Height="70" Cursor="Hand" Margin="2,5"  Name="xiazaiToolBarButton"  VerticalAlignment="Top" Click="xiazaiToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/jiaojieban.png"/>
                        <TextBlock><Run Text="更新菜品"/></TextBlock>
                    </StackPanel>
                </RadioButton>

                <RadioButton Width="80" Height="70" Cursor="Hand" Margin="2,5"  Name="exportToolBarButton"  VerticalAlignment="Top" Click="exportToolBarButton_Click" Style="{DynamicResource RDOButton}" SnapsToDevicePixels="True">
                    <StackPanel HorizontalAlignment="Center">
                        <Image Width="35" Height="35" Margin="0,5" Source="/MPCR.Client;component/Images/MakeupMenu.png"/>
                        <TextBlock><Run Text="制作菜谱"/></TextBlock>
                    </StackPanel>
                </RadioButton>


            </StackPanel>

 

个人非常喜欢,原创

效果图

 

最典型的应用 360 导航

 

 

自己感觉的,能做的,再和其他控件组合到一起,就帅了,是不是想到用它做个假的tab控件

目录
相关文章
|
9月前
|
存储 C# Windows
WPF技术之RadioButton控件
WPF(Windows Presentation Foundation)中的RadioButton控件用于创建单选按钮,允许用户从一组选项中选择一个。
783 0
|
区块链 C#
WPF如何实现一个漂亮的页签导航UI
原文:WPF如何实现一个漂亮的页签导航UI      最近看到一个比较漂亮的UI主界面,该UI是用左边的页签进行导航,比较有特色,就想着尝试用WPF来实现一下。经过一番尝试,基本上将UI设计图的效果用WPF程序进行了实现。
2081 0
|
前端开发 C#
silverlight,WPF动画终极攻略之番外 3D切换导航篇(Blend 4开发)
原文:silverlight,WPF动画终极攻略之番外 3D切换导航篇(Blend 4开发) 这篇介绍的是3D导航,点击图标,页面360°翻转的效果!有什么不足的欢迎大家指出来。 1.新建一个usercontrol,命名为menu. 2.按照下图设置一下属性。
1221 0
|
C#
潜移默化学会WPF(转载篇)--屏幕显示Label,鼠标移上去变成textBox
原文:潜移默化学会WPF(转载篇)--屏幕显示Label,鼠标移上去变成textBox ...
1035 0
|
C#
潜移默化学会WPF(难点控件treeview)--改造TreeView(CheckBox多选择版本),递归绑定数据
原文:潜移默化学会WPF(难点控件treeview)--改造TreeView(CheckBox多选择版本),递归绑定数据 目前自己对treeview的感慨很多 今天先讲 面对这种 表结构的数据 的其中一种绑定方法,后面多几列其他属性都没关系,例如多个字段, 1  A  0 2  B  0 3  C  0 4  D  1 5  E  2 6  F  4 7  G 1 .
2292 0
潜移默化学会WPF--值转换器
原文:潜移默化学会WPF--值转换器 1. binding 后面的stringFormat的写法----连接字符串         2. [ValueConversion(typeof(decimal), typeof(string))] public class Pr...
1140 0
|
C#
WPF MvvmLight简单实例(1) 页面导航
原文:WPF MvvmLight简单实例(1) 页面导航 实现了那些功能,先看看截图:   操作描述: 在程序运行后,点击“Load”按钮,页面会加载PageOne,点击PageOne页面中的“Next”按钮即可进入PageTwo页面, 点击PageTwo页面中的“Next”即可进...
1451 0
|
C# Shell 缓存
从PRISM开始学WPF(八)导航Navigation?
原文:从PRISM开始学WPF(八)导航Navigation? 0x6Navigation Basic Navigation Prism中的Navigation提供了一种类似导航的功能,他可以根据用户的输入,来刷新UI。
1409 0
|
C#
WPF自定义控件与样式(4)-CheckBox/RadioButton自定义样式
原文:WPF自定义控件与样式(4)-CheckBox/RadioButton自定义样式 一.前言   申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接。
2374 0
|
C# 容器
WPF笔记(1.2 Navigation导航)——Hello,WPF!
原文:WPF笔记(1.2 Navigation导航)——Hello,WPF!这一节是讲导航的。看了一遍,发现多不能实现,因为版本更新了,所以很多旧的语法不支持了,比如说,不再有NavigationApplication,仍然是Application,TextBlock容器的TextWrap属性改为TextingWrap,StartupUri指向"Page1.xaml"。
810 0