Skip to content

Commit 70530f3

Browse files
mgnslndhKeboo
authored andcommitted
Style for radio buttons inspired by Dragablz tabs (#598)
Style for radio buttons inspired by Drabablz tabs
1 parent af4b50a commit 70530f3

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

MainDemo.Wpf/Buttons.xaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
/>
288288
</Grid>
289289
</smtx:XamlDisplay>
290-
290+
291291
<smtx:XamlDisplay Key="buttons_27" Margin="5 0 0 0">
292292
<Grid Width="124">
293293
<Button Style="{StaticResource MaterialDesignRaisedButton}"
@@ -501,19 +501,19 @@
501501
</smtx:XamlDisplay>
502502
</StackPanel>
503503
<StackPanel Grid.Column="0" Grid.Row="3" Margin="0 16 0 0" Orientation="Horizontal">
504-
<smtx:XamlDisplay Key="buttons_53" Margin="5 0 0 0">
504+
<smtx:XamlDisplay Key="buttons_53" Margin="5 0 0 0" VerticalAlignment="Center">
505505
<ToggleButton Style="{StaticResource MaterialDesignFlatToggleButton}" ToolTip="MaterialDesignFlatToggleButton">
506506
<materialDesign:PackIcon Kind="Paperclip" Height="21" Width="21" />
507507
</ToggleButton>
508508
</smtx:XamlDisplay>
509-
<smtx:XamlDisplay Key="buttons_54" Margin="8 0 0 0" >
509+
<smtx:XamlDisplay Key="buttons_54" Margin="8 0 0 0" VerticalAlignment="Center" >
510510
<ToggleButton Style="{StaticResource MaterialDesignFlatPrimaryToggleButton}"
511511
ToolTip="MaterialDesignFlatPrimaryToggleButton"
512512
IsChecked="True">
513513
<materialDesign:PackIcon Kind="Heart" Height="21" Width="21" />
514514
</ToggleButton>
515515
</smtx:XamlDisplay>
516-
<smtx:XamlDisplay Key="buttons_55" Margin="8 0 0 0">
516+
<smtx:XamlDisplay Key="buttons_55" Margin="8 0 0 0" VerticalAlignment="Center">
517517
<ToggleButton Style="{StaticResource MaterialDesignFlatPrimaryToggleButton}"
518518
ToolTip="MaterialDesignFlatPrimaryToggleButton"
519519
IsEnabled="False">
@@ -566,6 +566,26 @@
566566
</ListBoxItem>
567567
</ListBox>
568568
</smtx:XamlDisplay>
569+
570+
<StackPanel Grid.Column="1" Grid.Row="3" Margin="2">
571+
<smtx:XamlDisplay Key="buttons_60" HorizontalAlignment="Left">
572+
<StackPanel Orientation="Horizontal" Margin="4">
573+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="True" Content="FIRST"/>
574+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="False" Content="SECOND"/>
575+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="False" Content="THIRD"/>
576+
</StackPanel>
577+
</smtx:XamlDisplay>
578+
<smtx:XamlDisplay Key="buttons_61" HorizontalAlignment="Left">
579+
<materialDesign:ColorZone Mode="PrimaryMid">
580+
<StackPanel Orientation="Horizontal" Margin="2" >
581+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="True" Content="FIRST"/>
582+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="False" Content="SECOND"/>
583+
<RadioButton Style="{StaticResource MaterialDesignTabRadioButton}" Margin="4" IsChecked="False" Content="THIRD"/>
584+
</StackPanel>
585+
</materialDesign:ColorZone>
586+
</smtx:XamlDisplay>
587+
588+
</StackPanel>
569589
</Grid>
570590

571591
<Border Grid.Row="9" Margin="0 16 0 0" BorderThickness="0 1 0 0" BorderBrush="{DynamicResource MaterialDesignDivider}" />

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.RadioButton.xaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
23
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
34
<ResourceDictionary.MergedDictionaries>
45
<ResourceDictionary Source="MaterialDesignTheme.ValidationErrorTemplate.xaml" />
@@ -13,6 +14,7 @@
1314
</Setter.Value>
1415
</Setter>
1516
</Style>
17+
1618
<Style x:Key="FocusVisual">
1719
<Setter Property="Control.Template">
1820
<Setter.Value>
@@ -22,6 +24,7 @@
2224
</Setter.Value>
2325
</Setter>
2426
</Style>
27+
2528
<Style x:Key="MaterialDesignRadioButton" TargetType="{x:Type RadioButton}">
2629
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
2730
<Setter Property="BorderThickness" Value="1"/>
@@ -214,4 +217,48 @@
214217
</Setter>
215218
</Style>
216219

220+
<Style x:Key="MaterialDesignTabRadioButton" TargetType="{x:Type RadioButton}">
221+
<Setter Property="FocusVisualStyle" Value="{StaticResource MaterialDesignFocusVisual}"/>
222+
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
223+
<Setter Property="Background" Value="Transparent"/>
224+
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
225+
<Setter Property="Padding" Value="16 4 16 4"/>
226+
<Setter Property="Height" Value="32" />
227+
<Setter Property="MinWidth" Value="80" />
228+
<Setter Property="wpf:RippleAssist.Feedback" Value="{DynamicResource MaterialDesignFlatButtonRipple}" />
229+
<Setter Property="TextBlock.FontWeight" Value="Medium"/>
230+
<Setter Property="TextBlock.FontSize" Value="14"/>
231+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
232+
<Setter Property="VerticalContentAlignment" Value="Center"/>
233+
<Setter Property="Template">
234+
<Setter.Value>
235+
<ControlTemplate TargetType="{x:Type RadioButton}">
236+
<Grid SnapsToDevicePixels="true">
237+
<Grid.RowDefinitions>
238+
<RowDefinition Height="*" />
239+
<RowDefinition Height="Auto" />
240+
</Grid.RowDefinitions>
241+
<Border Background="{TemplateBinding Background}">
242+
<wpf:Ripple Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Focusable="False"
243+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
244+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
245+
Padding="{TemplateBinding Padding}"
246+
x:Name="contentPresenter"
247+
Opacity=".82"
248+
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
249+
</Border>
250+
<Border x:Name="SelectionHighlightBorder" Background="{TemplateBinding BorderBrush}" Height="2"
251+
Grid.Row="1"
252+
Visibility="Hidden"/>
253+
</Grid>
254+
<ControlTemplate.Triggers>
255+
<Trigger Property="IsChecked" Value="True">
256+
<Setter TargetName="contentPresenter" Property="Opacity" Value="1"/>
257+
<Setter TargetName="SelectionHighlightBorder" Property="Visibility" Value="Visible" />
258+
</Trigger>
259+
</ControlTemplate.Triggers>
260+
</ControlTemplate>
261+
</Setter.Value>
262+
</Setter>
263+
</Style>
217264
</ResourceDictionary>

0 commit comments

Comments
 (0)