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 ...
随机推荐
- Cocos2d切换场景出现的问题-error C2653: “***”不是类或命名空间名称
1,在开头引入头文件 2,在要引入的头文件中,去除以下代码: #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #endif ...
- 慎用PHP的unset、array_unique方法
背景 在日常工作中,可能会经常遇到一些PHP的代码场景,需要我们去除数组中的某个项,通常会直接调用unset方法,但是如果用得不妥,会给自己挖坑 1.实操 以下使用具体例子进行证明假设有数组如下值: ...
- linux网络监控脚本
http://www.51testing.com/html/92/77492-828434.html
- BA--无风机冷却塔
无风机冷却塔的优点 1.无运转振动噪音传统冷却塔噪声源为冷却风扇马达运转所产生,其诱发之塔体振动,具有噪音共振加强性,为有效抑制振动之传导,须加装防震铁架及避震器.因冷却方式不同,LFC-N型无风机科 ...
- tableView计算动态行高的总结
研究tableView怎么计算动态行高研究了两天一直还不太会,今天最终做出来了想要的效果. 首先.我在网上搜集了非常多资料,各种大神的总结,然后開始看.研究.试验,基本思路都是一样的. 1.一定要将l ...
- android 九宫格(16宫格)控件
public class NineRectView extends ViewGroup { private Context ctx; private int wSize,hSize,row,colum ...
- Uva 12012 Detection of Extraterrestrial 求循环节个数为1-n的最长子串长度 KMP
题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=3163">点击打开链接 题意: ...
- php常用知识集锦
php常用知识集锦 很多位置都有写好的代码,自己做项目的时候可以直接拿来用,而不用自己写,比如现在看到的菜鸟教程. 1.判断是否为空 empty($_POST["name"]) 2 ...
- c:forTokens标签delims截取字符
转自:https://blog.csdn.net/love398146779/article/details/83853958 两个name要相同,在里边内容为空的时候才会全显示. <logic ...
- 3. Longest Substring Without Repeating Character[M] 最大不重复子串
题目 Given a string, find the length of the longest substring without repeating characters. Example 1: ...