feat: Add ButtonGroup control and styles.

This commit is contained in:
NaBian committed 2026-06-13 19:21:15 +08:00
1 parent 2ac7dfaf96
commit ee5c47a7cd
9 files changed
+690 -36

No files matched your search

@@ -0,0 +1,73 @@
<UserControl x:Class="HandyControlDemo.UserControl.ButtonGroupDemo"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="{DynamicResource RegionBrush}">
<TransitioningContentControl>
<ScrollViewer>
<hc:UniformSpacingPanel Margin="32" Spacing="32" ChildWrapping="Wrap" VerticalAlignment="Center">
<hc:UniformSpacingPanel Spacing="32" Orientation="Vertical">
<hc:ButtonGroup>
<RadioButton Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
</hc:ButtonGroup>
<hc:ButtonGroup>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
</hc:ButtonGroup>
<hc:ButtonGroup Theme="{StaticResource ButtonGroupSolid}">
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}" IsChecked="True"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
</hc:ButtonGroup>
<hc:ButtonGroup>
<RadioButton Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}" IsChecked="True"/>
</hc:ButtonGroup>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="32" ChildWrapping="Wrap">
<hc:ButtonGroup Orientation="Vertical">
<RadioButton Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
</hc:ButtonGroup>
<hc:ButtonGroup Orientation="Vertical">
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
</hc:ButtonGroup>
<hc:ButtonGroup Theme="{StaticResource ButtonGroupSolid}" Orientation="Vertical">
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}" IsChecked="True"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
</hc:ButtonGroup>
<hc:ButtonGroup Orientation="Vertical">
<RadioButton Content="{x:Static langs:Lang.RadioButton}" IsChecked="True"/>
<RadioButton Content="{x:Static langs:Lang.RadioButton}"/>
<Button Content="{x:Static langs:Lang.Button}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}"/>
<ToggleButton Content="{x:Static langs:Lang.ToggleButton}" IsChecked="True"/>
</hc:ButtonGroup>
</hc:UniformSpacingPanel>
</hc:UniformSpacingPanel>
</ScrollViewer>
</TransitioningContentControl>
</UserControl>
@@ -0,0 +1,9 @@
namespace HandyControlDemo.UserControl;
public partial class ButtonGroupDemo : Avalonia.Controls.UserControl
{
public ButtonGroupDemo()
{
InitializeComponent();
}
}
@@ -4,44 +4,47 @@
xmlns:vm="clr-namespace:HandyControlDemo.ViewModel"
xmlns:data="clr-namespace:HandyControlDemo.Data"
xmlns:cv="clr-namespace:HandyControlDemo.Tools.Converter"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
x:Class="HandyControlDemo.UserControl.HoneycombPanelDemo"
x:DataType="vm:CardDemoViewModel"
Background="{DynamicResource RegionBrush}"
DataContext="{Binding CardDemo, Source={x:Static vm:ViewModelLocator.Instance}}">
<UserControl.Resources>
<cv:StringToBitmapConverter x:Key="StringToBitmap" />
</UserControl.Resources>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"
Spacing="8"
Margin="0,0,0,16">
<Button Command="{Binding AddItemCommand}" Content="Add" />
<Button Command="{Binding RemoveItemCommand}" Content="Remove" />
</StackPanel>
<ItemsControl Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemsSource="{Binding DataList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<hc:HoneycombPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="data:CardModel">
<Border Width="60"
Height="60"
Margin="6"
CornerRadius="30"
ClipToBounds="True">
<Image Source="{Binding Content, Converter={StaticResource StringToBitmap}}"
Stretch="UniformToFill" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<TransitioningContentControl>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<hc:ButtonGroup Margin="0,0,0,16">
<Button Command="{Binding AddItemCommand}" Content="{x:Static langs:Lang.AddItem}" />
<Button Command="{Binding RemoveItemCommand}" Content="{x:Static langs:Lang.RemoveItem}" />
</hc:ButtonGroup>
<Border Grid.Row="1" Padding="0" Theme="{StaticResource BorderRegion}">
<ItemsControl HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemsSource="{Binding DataList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<hc:HoneycombPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="data:CardModel">
<Border Width="60"
Height="60"
Margin="6"
CornerRadius="30"
ClipToBounds="True">
<Image Source="{Binding Content, Converter={StaticResource StringToBitmap}}"
Stretch="UniformToFill" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Border>
</Grid>
</TransitioningContentControl>
</UserControl>
@@ -0,0 +1,134 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Layout;
using Avalonia.Styling;
using HandyControl.Data;
namespace HandyControl.Controls;
public class ButtonGroup : ItemsControl
{
public static readonly StyledProperty<Orientation> OrientationProperty =
StackPanel.OrientationProperty.AddOwner<ButtonGroup>(
new StyledPropertyMetadata<Orientation>(defaultValue: Orientation.Horizontal));
public Orientation Orientation
{
get => GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}
public static readonly StyledProperty<LinearLayout> LayoutProperty =
AvaloniaProperty.Register<ButtonGroup, LinearLayout>(nameof(Layout), defaultValue: LinearLayout.Uniform);
public LinearLayout Layout
{
get => GetValue(LayoutProperty);
set => SetValue(LayoutProperty, value);
}
static ButtonGroup()
{
AffectsMeasure<ButtonGroup>(OrientationProperty, LayoutProperty);
}
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
{
if (item is Button or RadioButton or ToggleButton)
{
recycleKey = null;
return false;
}
return base.NeedsContainerOverride(item, index, out recycleKey);
}
protected override void PrepareContainerForItemOverride(Control container, object? item, int index)
{
base.PrepareContainerForItemOverride(container, item, index);
container.PropertyChanged += Container_PropertyChanged;
UpdateItemThemes();
}
protected override void ClearContainerForItemOverride(Control container)
{
base.ClearContainerForItemOverride(container);
container.PropertyChanged -= Container_PropertyChanged;
UpdateItemThemes();
}
private void Container_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property == IsVisibleProperty)
{
UpdateItemThemes();
}
}
private void UpdateItemThemes()
{
var visibleButtons = Items.OfType<Button>().Where(b => b.IsVisible).ToList();
var count = visibleButtons.Count;
if (count == 0)
{
return;
}
for (var i = 0; i < count; i++)
{
var button = visibleButtons[i];
var theme = ResolveTheme(button, i, count);
if (theme != null)
{
button.SetCurrentValue(ThemeProperty, theme);
}
}
}
private ControlTheme? ResolveTheme(Button button, int index, int count)
{
var key = button switch
{
RadioButton => GetThemeKey(index, count, "RadioGroupItem"),
ToggleButton => GetThemeKey(index, count, "ToggleButtonGroupItem"),
_ => GetThemeKey(index, count, "ButtonGroupItem")
};
if (key == null)
{
return null;
}
if (this.TryFindResource(key, out var resource) && resource is ControlTheme theme)
{
return theme;
}
return null;
}
private string? GetThemeKey(int index, int count, string prefix)
{
if (count == 1)
{
return prefix + "Single";
}
if (index == 0)
{
return prefix + (Orientation == Orientation.Horizontal ? "HorizontalFirst" : "VerticalFirst");
}
if (index == count - 1)
{
return prefix + (Orientation == Orientation.Horizontal ? "HorizontalLast" : "VerticalLast");
}
return prefix + "Default";
}
}
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls">
@@ -455,6 +455,117 @@
Value="12" />
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemBaseStyle"
TargetType="Button">
<Setter Property="Background"
Value="{DynamicResource RegionBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="hc:BorderElement.CornerRadius"
Value="0" />
<Setter Property="CornerRadius"
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
<Setter Property="Height"
Value="{StaticResource DefaultControlHeight}" />
<Setter Property="Padding"
Value="10,0" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<Border x:Name="BorderRoot"
CornerRadius="{TemplateBinding CornerRadius}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}">
<Path x:Name="PathMain"
Width="{TemplateBinding hc:IconElement.Width}"
Height="{TemplateBinding hc:IconElement.Height}"
Fill="{TemplateBinding Foreground}"
IsVisible="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}"
Stretch="Uniform"
Data="{TemplateBinding hc:IconElement.Geometry}" />
<ContentPresenter x:Name="contentPresenter"
RecognizesAccessKey="True"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
</StackPanel>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background"
Value="{DynamicResource SecondaryRegionBrush}" />
<Style Selector="^ /template/ ContentPresenter#contentPresenter">
<Setter Property="Foreground"
Value="{DynamicResource PrimaryBrush}" />
</Style>
</Style>
<Style Selector="^:pressed">
<Setter Property="Background"
Value="{DynamicResource BorderBrush}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Opacity"
Value="0.4" />
</Style>
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemDefault"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button" />
<ControlTheme x:Key="ButtonGroupItemHorizontalFirst"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,0,0,4" />
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemHorizontalLast"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,4,4,0" />
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemSingle"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button">
<Setter Property="hc:BorderElement.CornerRadius"
Value="{StaticResource DefaultCornerRadius}" />
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemVerticalFirst"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,4,0,0" />
</ControlTheme>
<ControlTheme x:Key="ButtonGroupItemVerticalLast"
BasedOn="{StaticResource ButtonGroupItemBaseStyle}"
TargetType="Button">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,0,4,4" />
</ControlTheme>
<ControlTheme x:Key="ButtonCustom"
TargetType="Button">
<Setter Property="Foreground"
@@ -0,0 +1,67 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls">
<ItemsPanelTemplate x:Key="ButtonGroupHorizontalUniformItemsPanelTemplate">
<UniformGrid Rows="1" />
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="ButtonGroupVerticalUniformItemsPanelTemplate">
<UniformGrid Columns="1" />
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="ButtonGroupHorizontalStackItemsPanelTemplate">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="ButtonGroupVerticalStackItemsPanelTemplate">
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
<ControlTheme x:Key="ButtonGroupBaseStyle"
TargetType="hc:ButtonGroup">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Layout" Value="Uniform" />
<Setter Property="Focusable" Value="False" />
<Setter Property="ItemsPanel" Value="{StaticResource ButtonGroupHorizontalUniformItemsPanelTemplate}" />
<Setter Property="hc:VisualElement.HighlightBorderBrush" Value="{DynamicResource PrimaryBrush}" />
<Setter Property="hc:VisualElement.HighlightBackground" Value="{DynamicResource RegionBrush}" />
<Setter Property="hc:VisualElement.HighlightForeground" Value="{DynamicResource PrimaryBrush}" />
<Setter Property="Template">
<ControlTemplate TargetType="hc:ButtonGroup">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ItemsPresenter Name="PART_ItemsPresenter"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^[Layout=Uniform][Orientation=Vertical]">
<Setter Property="ItemsPanel" Value="{StaticResource ButtonGroupVerticalUniformItemsPanelTemplate}" />
</Style>
<Style Selector="^[Layout=Stack][Orientation=Horizontal]">
<Setter Property="ItemsPanel" Value="{StaticResource ButtonGroupHorizontalStackItemsPanelTemplate}" />
</Style>
<Style Selector="^[Layout=Stack][Orientation=Vertical]">
<Setter Property="ItemsPanel" Value="{StaticResource ButtonGroupVerticalStackItemsPanelTemplate}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type hc:ButtonGroup}"
BasedOn="{StaticResource ButtonGroupBaseStyle}"
TargetType="hc:ButtonGroup" />
<ControlTheme x:Key="ButtonGroupSolid"
BasedOn="{StaticResource ButtonGroupBaseStyle}"
TargetType="hc:ButtonGroup">
<Setter Property="hc:VisualElement.HighlightBorderBrush" Value="{DynamicResource TitleBrush}" />
<Setter Property="hc:VisualElement.HighlightBackground" Value="{DynamicResource TitleBrush}" />
<Setter Property="hc:VisualElement.HighlightForeground" Value="{DynamicResource TextIconBrush}" />
</ControlTheme>
</ResourceDictionary>
@@ -59,6 +59,7 @@
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/HeaderedContentControl.axaml" />
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/Card.axaml" />
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/ElementGroup.axaml" />
<MergeResourceInclude Source="avares://HandyControl/Themes/Styles/ButtonGroup.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>
@@ -1,4 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls">
@@ -215,4 +215,134 @@
<Setter Property="hc:IconElement.Height"
Value="12" />
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemBaseStyle"
TargetType="RadioButton">
<Setter Property="Background"
Value="{DynamicResource RegionBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="hc:BorderElement.CornerRadius"
Value="0" />
<Setter Property="CornerRadius"
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
<Setter Property="Height"
Value="{StaticResource DefaultControlHeight}" />
<Setter Property="Padding"
Value="10,0" />
<Setter Property="hc:IconElement.Width"
Value="16" />
<Setter Property="hc:IconElement.Height"
Value="16" />
<Setter Property="Template">
<ControlTemplate TargetType="RadioButton">
<Border x:Name="BorderRoot"
CornerRadius="{TemplateBinding CornerRadius}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}">
<Path x:Name="PathMain"
Width="{TemplateBinding hc:IconElement.Width}"
Height="{TemplateBinding hc:IconElement.Height}"
Fill="{Binding $parent[RadioButton].Foreground}"
IsVisible="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}"
Stretch="Uniform"
Data="{TemplateBinding hc:IconElement.Geometry}" />
<ContentPresenter x:Name="contentPresenter"
RecognizesAccessKey="True"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
</StackPanel>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background"
Value="{DynamicResource SecondaryRegionBrush}" />
<Style Selector="^ /template/ ContentPresenter#contentPresenter">
<Setter Property="Foreground"
Value="{DynamicResource PrimaryBrush}" />
</Style>
</Style>
<Style Selector="^:pressed">
<Setter Property="Background"
Value="{DynamicResource BorderBrush}" />
</Style>
<Style Selector="^:checked">
<Setter Property="ZIndex"
Value="2147483647" />
<Style Selector="^ /template/ Border#BorderRoot">
<Setter Property="BorderBrush"
Value="{Binding $parent[RadioButton].(hc:VisualElement.HighlightBorderBrush)}" />
<Setter Property="Background"
Value="{Binding $parent[RadioButton].(hc:VisualElement.HighlightBackground)}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#contentPresenter">
<Setter Property="Foreground"
Value="{Binding $parent[RadioButton].(hc:VisualElement.HighlightForeground)}" />
</Style>
</Style>
<Style Selector="^:disabled">
<Setter Property="Opacity"
Value="0.4" />
</Style>
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemDefault"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton" />
<ControlTheme x:Key="RadioGroupItemHorizontalFirst"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,0,0,4" />
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemHorizontalLast"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,4,4,0" />
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemSingle"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="{StaticResource DefaultCornerRadius}" />
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemVerticalFirst"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,4,0,0" />
</ControlTheme>
<ControlTheme x:Key="RadioGroupItemVerticalLast"
BasedOn="{StaticResource RadioGroupItemBaseStyle}"
TargetType="RadioButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,0,4,4" />
</ControlTheme>
</ResourceDictionary>
@@ -769,4 +769,130 @@
<Setter Property="Width"
Value="20" />
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemBaseStyle"
TargetType="ToggleButton">
<Setter Property="Background"
Value="{DynamicResource RegionBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrush}" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="hc:BorderElement.CornerRadius"
Value="0" />
<Setter Property="CornerRadius"
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
<Setter Property="Height"
Value="{StaticResource DefaultControlHeight}" />
<Setter Property="Padding"
Value="10,0" />
<Setter Property="Template">
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="BorderRoot"
CornerRadius="{TemplateBinding CornerRadius}"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{TemplateBinding BorderBrush}">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}">
<Path x:Name="PathMain"
Width="{TemplateBinding hc:IconElement.Width}"
Height="{TemplateBinding hc:IconElement.Height}"
Fill="{TemplateBinding Foreground}"
IsVisible="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}"
Stretch="Uniform"
Data="{TemplateBinding hc:IconElement.Geometry}" />
<ContentPresenter x:Name="contentPresenter"
RecognizesAccessKey="True"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}"
Margin="{Binding Path=(hc:IconElement.Geometry), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource GeometrySpacingConverter}, ConverterParameter='6,0,0,0'}" />
</StackPanel>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Background"
Value="{DynamicResource SecondaryRegionBrush}" />
<Style Selector="^ /template/ ContentPresenter#contentPresenter">
<Setter Property="Foreground"
Value="{DynamicResource PrimaryBrush}" />
</Style>
</Style>
<Style Selector="^:pressed">
<Setter Property="Background"
Value="{DynamicResource BorderBrush}" />
</Style>
<Style Selector="^:checked">
<Setter Property="ZIndex"
Value="2147483647" />
<Style Selector="^ /template/ Border#BorderRoot">
<Setter Property="BorderBrush"
Value="{Binding $parent[ToggleButton].(hc:VisualElement.HighlightBorderBrush)}" />
<Setter Property="Background"
Value="{Binding $parent[ToggleButton].(hc:VisualElement.HighlightBackground)}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#contentPresenter">
<Setter Property="Foreground"
Value="{Binding $parent[ToggleButton].(hc:VisualElement.HighlightForeground)}" />
</Style>
</Style>
<Style Selector="^:disabled">
<Setter Property="Opacity"
Value="0.4" />
</Style>
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemDefault"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton" />
<ControlTheme x:Key="ToggleButtonGroupItemHorizontalFirst"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,0,0,4" />
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemHorizontalLast"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,4,4,0" />
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemSingle"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="{StaticResource DefaultCornerRadius}" />
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemVerticalFirst"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="4,4,0,0" />
</ControlTheme>
<ControlTheme x:Key="ToggleButtonGroupItemVerticalLast"
BasedOn="{StaticResource ToggleButtonGroupItemBaseStyle}"
TargetType="ToggleButton">
<Setter Property="hc:BorderElement.CornerRadius"
Value="0,0,4,4" />
</ControlTheme>
</ResourceDictionary>