WPF Radiobuttong go to the front dot, custom radiobutton style

Source: Internet
Author: User

Custom RadioButton Style code:

<windows. Resources>

<lineargradientbrush x:key= "Checkradiofillnormal" >
<gradientstop color= "#FFD2D4D2" offset= "0"/>
<gradientstop color= "#FFFFFFFF" offset= "1"/>
</LinearGradientBrush>
<lineargradientbrush x:key= "Checkradiostrokenormal" >
<gradientstop color= "#FF004C94" offset= "0"/>
<gradientstop color= "#FF003C74" offset= "1"/>
</LinearGradientBrush>
<style x:key= "Checkradiofocusvisual" >
<setter property= "Control.template" >
<Setter.Value>
<ControlTemplate>
<rectangle margin= "14,0,0,0" snapstodevicepixels= "true" stroke= "{DynamicResource {x:static Systemcolors.controltextbrushkey}} "strokethickness=" 1 "strokedasharray=" 1 2 "/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<style x:key= "Radiobuttoncolorstyle" targettype= "{x:type RadioButton}" >
<setter property= "Foreground" value= "{dynamicresource {x:static Systemcolors.controltextbrushkey}}"/>
<setter property= "Background" value= "{StaticResource checkradiofillnormal}"/>
<setter property= "BorderBrush" value= "{StaticResource checkradiostrokenormal}"/>
<setter property= "BorderThickness" value= "1"/>
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "{x:type RadioButton}" >
<Grid>
<!--background color transparency border radians--
<rectangle x:name= "Rectangle" fill= "Lightgray" stroke= "Black" opacity= "1" radiusx= "0" radiusy= "0" strokethickness= "0"/>
<!--font color, font size--
<textblock x:name= "TextBlock" margin= "8,0" textwrapping= "Wrap" text= "{TemplateBinding Content}" Horizontalalignment= "Center" verticalalignment= "center" height= "27.137" fontsize= "18.667" foreground= "Black"/>
</Grid>
<ControlTemplate.Triggers>
<trigger property= "GroupName" value= ""/>
<trigger property= "GroupName" value= ""/>
<!--mouse click Trigger, background Color--
<trigger property= "IsChecked" value= "True" >
<setter property= "Fill" targetname= "Rectangle" value= "#8B0000"/>
<setter property= "Opacity" targetname= "Rectangle" value= "1"/>
<setter property= "Foreground" targetname= "TextBlock" >
<Setter.Value>
<LinearGradientBrush>
<!--mouse click Trigger, modify font Color--
<gradientstop color= "#FFFFFF" offset= "0"/>
<gradientstop color= "#FFFFFF" offset= "1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<!--mouse Move-out trigger--
<trigger property= "IsMouseOver" value= "True" >
<setter property= "Effect" targetname= "Rectangle" value= "{x:null}"/>
<setter property= "Fill" targetname= "Rectangle" value= "#AAAAAA"/>
</Trigger>
<trigger property= "Hascontent" value= "true" >
<setter property= "FocusVisualStyle" value= "{StaticResource checkradiofocusvisual}"/>
<setter property= "Padding" value= "2,0,0,0"/>
</Trigger>
<trigger property= "IsEnabled" value= "false" >
<setter property= "Foreground" value= "{dynamicresource {x:static Systemcolors.graytextbrushkey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

</windows. Resources>

Calling the RadioButton style code

<radiobutton content= "User Management" Name= "Usermanager" fontsize= "+" verticalcontentalignment= "Center" Horizontalalignment= "Stretch" grid.row= "4" verticalalignment= "Stretch" margin= "0,0,0,0" checked= "Rbusermanager_ Checked " style=" {DynamicResource radiobuttoncolorstyle} "/>

WPF Radiobuttong go to the front dot, custom radiobutton style

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.