在wpf中设置radiobuton的边框 [英] Set border for radiobuton in wpf

查看:201
本文介绍了在wpf中设置radiobuton的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有2个单选按钮rd1和rd2设置的样式是按钮,

我想在用户点击时在rd2 - >为rd2设置边框并清除边框rd1

当用户点击rd1 - >为rd1设置berdor并清除rd2的边框。





i是新的WPF,所以请帮帮我



感谢advence

解决方案

如果你想在选定和未选择的RadioButtons之间显示外观和感觉上的差异,你可以使用一些主题。



由于你是WPF新手,我建议使用Infragistics Metro Light主题。并且,您需要将您的RadioButton样式设置为ToggleButton,例如



 <   radiobutton     name   =  rd1    groupname   = 测试   已删除  = 选项1    style   =  {StaticResource {x:Type ToggleButton}}    /  < span class =code-keyword>>  
< radiobutton name = rd2 groupname = 测试 已移除 = 选项2 style = {StaticResource {x:Type ToggleButton}} / >





应用主题:

在Visual Studio中,转到查看菜单 - >打开程序包管理器控制台其他Windows - > 包管理器控制台



然后,在包管理器控制台中复制并粘贴以下命令,然后按enter键。

安装主题需要一点时间。



 Install-Package Infragistics.Themes.MetroLight.Wpf 





之后,打开项目中显示的 App.xaml ,并粘贴以下代码



 <   ResourceDictionary  >  
< ResourceDictionary.MergedDictionaries >
< ResourceDictionary 来源 = < span class =code- keyword> Themes / Metro / Metro.MSControls.Core.Implicit.xaml / >
< ResourceDictionary 来源 = Themes / Metro / Metro.MSControls.Toolkit.Implicit.xaml / >
< / ResourceDictionary.MergedDictionaries >
< / ResourceDictionary >





介于两者之间



<前朗=xml> < application.resources > <! - 粘贴此处 < span class =code-comment> - > < / application。资源 >





现在编译并运行你的项目,您将在选定和未选择的选项(radiobuttons)之间获得明显的外观和感觉差异。



如果我的答案满足您的需求,请通知。



谢谢。


Hi All

I have 2 radio button rd1 and rd2 which were set style is button,
I want to when user click on rd2 -> set border for rd2 and clear border rd1
and when user click on rd1 -> set berdor for rd1 and clear border of rd2.


i am new WPF, so please help me

thanks in advence

解决方案

In case, if you want to show difference in look and feel between selected and unselected RadioButtons, you can use some themes.

As you are new to WPF, I suggest Infragistics Metro Light theme. And, you need to set your RadioButton style to ToggleButton like

<radiobutton name="rd1" groupname="Test" removed="Option 1" style="{StaticResource {x:Type ToggleButton}}" />
<radiobutton name="rd2" groupname="Test" removed="Option 2" style="{StaticResource {x:Type ToggleButton}}" />



Applying theme:
In your Visual Studio, open Package Manager Console by going to View menu -> Other Windows -> Package Manager Console

Then, copy and paste following command in your Package Manager Console and press enter.
It will take little moment to install theme.

Install-Package Infragistics.Themes.MetroLight.Wpf



After that, Open your App.xaml presented in your project, and Paste following code

<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/Metro/Metro.MSControls.Core.Implicit.xaml" />
                <ResourceDictionary Source="Themes/Metro/Metro.MSControls.Toolkit.Implicit.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>



in between

<application.resources> <!-- paste here --> </application.resources>



Now compile and run your project, you will get clear differentiation in look and feel between selected and unselected options(radiobuttons) .

Please notify if my answer is satisfy your need.

Thank you.


这篇关于在wpf中设置radiobuton的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆