wpf radiobuttong 去前面的圓點, 自訂radiobutton樣式

來源:互聯網
上載者:User

標籤:system   control   ios   nes   bsp   res   windows   binding   resource   

自訂radiobutton樣式代碼:

<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>
<!--背景顏色 透明度 邊框弧度-->
<Rectangle x:Name="rectangle" Fill="LightGray" Stroke="Black" Opacity="1" RadiusX="0" RadiusY="0" StrokeThickness="0"/>
<!--字型顏色, 字型大小-->
<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=""/>
<!--滑鼠點擊觸發器, 背景顏色-->
<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>
<!--滑鼠點擊觸發器, 修改字型顏色-->
<GradientStop Color="#FFFFFF" Offset="0"/>
<GradientStop Color="#FFFFFF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</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>

 

調用radiobutton樣式代碼

<RadioButton Content="使用者管理" Name="UserManager" FontSize="18" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" Grid.Row="4" VerticalAlignment="Stretch" Margin="0,0,0,0" Checked="RBUserManager_Checked" Style="{DynamicResource RadioButtonColorStyle}"/>

wpf radiobuttong 去前面的圓點, 自訂radiobutton樣式

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.