WPF利用radiobutton制作菜单按钮
版权声明:欢迎转载。转载请注明出处,谢谢 https://blog.csdn.net/wzcool273509239/article/details/56480631
实现功能:鼠标移入和选中高亮显示,话不多说,直接上样式。
样式:
<!--========================================================RadioButton 样式 通用====================================-->
<Style x:Key="Tong_Yong_RadioButtonStyle" TargetType="{x:Type RadioButton}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<!--<Setter Property="Background" Value="#F4F4F4"/>
<Setter Property="BorderBrush" Value="{StaticResource CheckBoxStroke}"/>-->
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="10,10,0,0"></Setter>
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Height" Value="{Binding Height}"></Setter>
<Setter Property="Width" Value="{Binding Width}"></Setter>
<Setter Property="Cursor" Value="Hand"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RadioButton}">
<Grid>
<!--选中或者鼠标移入颜色-->
<Grid x:Name="B" Visibility="Collapsed" Background="{TemplateBinding BorderBrush}"/>
<!--默认颜色-->
<Grid x:Name="A" Background="{TemplateBinding Background}"/>
<ContentPresenter x:Name="contentPresenter" RecognizesAccessKey="True" Visibility="Collapsed"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Visibility" TargetName="A" Value="Collapsed"/>
<Setter Property="Visibility" TargetName="B" Value="Visible"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<!--<Setter Property="Visibility" TargetName="contentPresenter" Value="Visible"/>-->
<Setter Property="Visibility" TargetName="A" Value="Collapsed"/>
<Setter Property="Visibility" TargetName="B" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--========================================================RadioButton 样式 通用====================================-->
引用实例:
<!--首页-->
<RadioButton Name="rbHome" Style="{DynamicResource Tong_Yong_RadioButtonStyle}" Width="192" Height="63" IsChecked="True" Checked="RadioButton_Checked">
<RadioButton.Background>
<ImageBrush ImageSource="/Agriculture.CommonUserControl;component/Images/MenuImages/home-.png"/>
</RadioButton.Background>
<RadioButton.BorderBrush>
<ImageBrush ImageSource="/Agriculture.CommonUserControl;component/Images/MenuImages/home.png"/>
</RadioButton.BorderBrush>
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/Agriculture.CommonUserControl;component/Images/MenuImages/home.png"/>
</Grid.Background>
</Grid>
</RadioButton>
WPF利用radiobutton制作菜单按钮的更多相关文章
- WPF利用Image实现图片按钮
之前有一篇文章也是采用了Image实现的图片按钮,不过时间太久远了,忘记了地址.好吧,这里我进行了进一步的改进,原来的文章中需要设置4张图片,分别为可用时,鼠标悬浮时,按钮按下时,按钮不可用时的图片, ...
- wpf利用线程制作初始界面和关闭窗体特效
1.首先定义初始窗体,和主窗体. 初始窗体(StartWindow) 主窗体(MainWindow): 2.在主窗体界面中,加载初始窗体.注意在线程中操作UI元素需要使用BeginInvoke或者In ...
- 利用CSS制作背景变色的横向导航栏
1.表单 页面如下: <html> <head> <title>注册表单页面</title> </head> <body> &l ...
- 利用WIX制作安装包(2)
原文 利用WIX制作安装包(2) 这一篇文章将为大家介绍如何使用WIX自定义UI.上一篇文章我们讲过WIX为我们提供了五种安装界面.每种安装界面都是由不同的Dialog组成.在这里我们挑选一种比较常用 ...
- 利用Word2010制作流程图
利用Word2010制作流程图 原文链接:https://www.toutiao.com/i6483034968225235469/ 一.页面和段落的设置 启动Word2010,打开一个空白文档,并切 ...
- Expression Blend制作自定义按钮(转)
来源:http://www.cnblogs.com/iChina/archive/2011/11/25/2262854.html Expression Blend制作自定义按钮 1.从Blend工具箱 ...
- 【百度地图API】如何利用PhoneGap制作地图APP
原文:[百度地图API]如何利用PhoneGap制作地图APP 摘要:百度地图API是一套由javascript编写的地图程序接口,按说它应该运行在浏览器上.现在,只要利用PhoneGap,我们就能开 ...
- bootstrap学习笔记(菜单.按钮)
下拉菜单 <div class="dropdown"> <button class="btn btn-default dropdown-toggle&q ...
- Bootstrap学习-菜单-按钮-导航
1.下拉菜单(基本用法) 在使用Bootstrap框架的下拉菜单时,必须调用Bootstrap框架提供的bootstrap.js文件.当然,如果你使用的是未编译版本,在js文件夹下你能找到一个名为“d ...
随机推荐
- 用Python图像处理
前几天弄了下django的图片上传,上传之后还需要做些简单的处理,python中PIL模块就是专门用来做这个事情的. 于是照葫芦画瓢做了几个常用图片操作,在这里记录下,以便备用. 这里有个字体文件,大 ...
- 关于ajax异步请求不到数据的问题 302跨域请求
项目大致问题是这样的 在线咨询模块的数据是通过ajax异步加载来请求到数据,然后动态解析并且显示 前台页面的请求代码 后台action: 另外就是这个项目还有一个登陆权限的认证,如果不登录后台或者登录 ...
- ZOJ 2314 Reactor Cooling
Reactor Cooling Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...
- Innodb性能优化之参数设置
现在,Innodb是Mysql最多使用的存储引擎.其性能一直广受关注.本文通过基本的参数设置来提高其性能. innodb_buffer_pool_size 缓冲池大小.这是innodb参数中最重要的设 ...
- BA-siemens-apogee-ppcl
adapts函数的使用 常规控制风机及阀门的程序是使用PID来调节,但是自适应算法能更好的调节. 西门子的自适应调节函数adapts用法如下: 以下文章为网络转载,原文链接地址http://news. ...
- Jmeter简单应用
JMeter 是Apache组织的开源项目,是一个纯Java桌面应用,用于压力测试和性能测量. 1.安装jmeter jdk1.6以上下载地址:http://www.oracle.com/techne ...
- Project Euler:Problem 88 Product-sum numbers
A natural number, N, that can be written as the sum and product of a given set of at least two natur ...
- hdu 5031 Lines 爆搜
事实上嘞,这个线能够仅仅延伸一端 然后嘞,爆搜一次就能够 最后嘞,600-800ms过 本弱就是弱啊.你来打我呀-- #include<iostream> #include<cstr ...
- css sprite的实现
css sprite 为什么使用css sprite? 网页上的非常多静态小图片在载入时须要大量http请求,添加了响应时间.(哈哈.雅虎34条优化法则的第一条啊) css的background-po ...
- POJ 3411 DFS
大致题意: 有n座城市和m(1<=n,m<=10)条路.现在要从城市1到城市n.有些路是要收费的,从a城市到b城市,如果之前到过c城市,那么只要付P的钱,如果没有去过就付R的钱.求的是最少 ...