Skip to content

Commit ba02e51

Browse files
committed
Fix for animations and adding ButtonSegmentedStyle
1 parent 61c7d92 commit ba02e51

File tree

4 files changed

+509
-72
lines changed

4 files changed

+509
-72
lines changed

components/SegmentedControl/samples/SegmentedControl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ The `Segmented` control is best used with 2-5 items and does not support overflo
3535

3636
## Other styles
3737

38-
The `Segmented` control contains various additional styles, to match the look and feel of your application. The `PillSegmentedStyle` matches a modern `Pivot` and `NavigationView` style.
38+
The `Segmented` control contains various additional styles, to match the look and feel of your application. The `PivotSegmentedStyle` matches a modern `Pivot` style while the `ButtonSegmentedStyle` represents buttons.
3939

4040
> [!SAMPLE SegmentedControlStylesSample]

components/SegmentedControl/samples/SegmentedControlStylesSample.xaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,21 @@
3131
Text="PivotSegmentedStyle" />
3232
<labs:Segmented SelectedIndex="0"
3333
SelectionMode="{x:Bind local:SegmentedControlStylesSample.ConvertStringToSelectionMode(SelectionMode), Mode=OneWay}"
34-
Style="{StaticResource PivotSegmentedStyle}">
35-
<labs:SegmentedItem ToolTipService.ToolTip="Day view">
34+
Style="{StaticResource ButtonSegmentedStyle}">
35+
<labs:SegmentedItem Content="Day"
36+
ToolTipService.ToolTip="Day view">
3637
<labs:SegmentedItem.Icon>
3738
<FontIcon Glyph="&#xE161;" />
3839
</labs:SegmentedItem.Icon>
3940
</labs:SegmentedItem>
40-
<labs:SegmentedItem ToolTipService.ToolTip="Week view">
41+
<labs:SegmentedItem Content="Week"
42+
ToolTipService.ToolTip="Week view">
4143
<labs:SegmentedItem.Icon>
4244
<FontIcon Glyph="&#xE162;" />
4345
</labs:SegmentedItem.Icon>
4446
</labs:SegmentedItem>
45-
<labs:SegmentedItem ToolTipService.ToolTip="Month view">
47+
<labs:SegmentedItem Content="Month"
48+
ToolTipService.ToolTip="Month view">
4649
<labs:SegmentedItem.Icon>
4750
<FontIcon Glyph="&#xE163;" />
4851
</labs:SegmentedItem.Icon>

components/SegmentedControl/src/Segmented/Segmented.xaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:labs="using:CommunityToolkit.Labs.WinUI"
44
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
@@ -31,6 +31,7 @@
3131
</ResourceDictionary.ThemeDictionaries>
3232

3333
<x:Double x:Key="SegmentedItemSpacing">1</x:Double>
34+
<x:Double x:Key="ButtonItemSpacing">2</x:Double>
3435

3536
<Style BasedOn="{StaticResource DefaultSegmentedStyle}"
3637
TargetType="labs:Segmented" />
@@ -95,4 +96,24 @@
9596
</Setter>
9697
</Style.Setters>
9798
</Style>
99+
100+
<Style x:Key="ButtonSegmentedStyle"
101+
BasedOn="{StaticResource DefaultSegmentedStyle}"
102+
TargetType="labs:Segmented">
103+
<Style.Setters>
104+
<Setter Property="Background" Value="Transparent" />
105+
<Setter Property="BorderBrush" Value="Transparent" />
106+
<Setter Property="BorderThickness" Value="0" />
107+
<Setter Property="Padding" Value="0" />
108+
<Setter Property="ItemContainerStyle" Value="{StaticResource ButtonSegmentedItemStyle}" />
109+
<Setter Property="ItemsPanel">
110+
<Setter.Value>
111+
<ItemsPanelTemplate>
112+
<StackPanel Orientation="Horizontal"
113+
Spacing="{ThemeResource ButtonItemSpacing}" />
114+
</ItemsPanelTemplate>
115+
</Setter.Value>
116+
</Setter>
117+
</Style.Setters>
118+
</Style>
98119
</ResourceDictionary>

0 commit comments

Comments
 (0)