Skip to content

Commit fe533f5

Browse files
committed
Added vertical behavior for the PivotSegmentedStyle
1 parent aa68ff5 commit fe533f5

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

components/Segmented/src/Segmented/Segmented.xaml

Lines changed: 3 additions & 2 deletions
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:local="using:CommunityToolkit.WinUI.Controls"
44
xmlns:tk="using:CommunityToolkit.WinUI"
@@ -93,7 +93,8 @@
9393
<Setter Property="ItemsPanel">
9494
<Setter.Value>
9595
<ItemsPanelTemplate>
96-
<StackPanel Orientation="Horizontal"
96+
<StackPanel tk:FrameworkElementExtensions.AncestorType="local:Segmented"
97+
Orientation="{Binding (tk:FrameworkElementExtensions.Ancestor).Orientation, RelativeSource={RelativeSource Self}}"
9798
Spacing="{ThemeResource SegmentedItemSpacing}" />
9899
</ItemsPanelTemplate>
99100
</Setter.Value>

components/Segmented/src/SegmentedItem/SegmentedItem.xaml

Lines changed: 34 additions & 33 deletions
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:local="using:CommunityToolkit.WinUI.Controls"
44
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
@@ -665,7 +665,6 @@
665665
</Viewbox>
666666

667667
<ContentPresenter x:Name="PART_ContentPresenter"
668-
Grid.Column="1"
669668
Margin="0,5,0,6"
670669
VerticalAlignment="Center"
671670
win:HighContrastAdjustment="None"
@@ -713,19 +712,26 @@
713712
Control.IsTemplateFocusTarget="True"
714713
CornerRadius="{TemplateBinding CornerRadius}">
715714
<VisualStateManager.VisualStateGroups>
715+
<VisualStateGroup x:Name="SegmentedOrientationStates">
716+
<VisualState x:Name="Horizontal" />
717+
<VisualState x:Name="Vertical">
718+
<VisualState.Setters>
719+
<Setter Target="PART_Pill.HorizontalAlignment" Value="Left" />
720+
<Setter Target="PART_Pill.VerticalAlignment" Value="Center" />
721+
<Setter Target="PART_Pill.(UIElement.RenderTransform).(CompositeTransform.Rotation)" Value="90" />
722+
</VisualState.Setters>
723+
</VisualState>
724+
</VisualStateGroup>
716725
<VisualStateGroup x:Name="SegmentedIconPositionStates">
717-
<VisualState x:Name="IconOnLeft" />
726+
<VisualState x:Name="IconLeft" />
718727
<VisualState x:Name="IconOnly">
719728
<VisualState.Setters>
720729
<Setter Target="PART_ContentPresenter.Visibility" Value="Collapsed" />
721-
<Setter Target="PART_Pill.(Grid.Column)" Value="0" />
722-
<Setter Target="ContentHolder.ColumnSpacing" Value="0" />
723730
</VisualState.Setters>
724731
</VisualState>
725732
<VisualState x:Name="ContentOnly">
726733
<VisualState.Setters>
727734
<Setter Target="PART_IconBox.Visibility" Value="Collapsed" />
728-
<Setter Target="ContentHolder.ColumnSpacing" Value="0" />
729735
</VisualState.Setters>
730736
</VisualState>
731737
</VisualStateGroup>
@@ -878,15 +884,11 @@
878884
</VisualStateManager.VisualStateGroups>
879885

880886
<!-- Content -->
881-
<Grid x:Name="ContentHolder"
882-
Margin="12,0,12,0"
883-
HorizontalAlignment="Center"
884-
VerticalAlignment="Stretch"
885-
ColumnSpacing="8">
886-
<Grid.ColumnDefinitions>
887-
<ColumnDefinition Width="Auto" />
888-
<ColumnDefinition Width="Auto" />
889-
</Grid.ColumnDefinitions>
887+
<StackPanel x:Name="ContentHolder"
888+
Margin="12,0,12,0"
889+
HorizontalAlignment="Center"
890+
VerticalAlignment="Stretch"
891+
Spacing="8">
890892
<Viewbox x:Name="PART_IconBox"
891893
Width="16"
892894
Margin="0,11,0,11"
@@ -898,7 +900,6 @@
898900
</Viewbox>
899901

900902
<ContentPresenter x:Name="PART_ContentPresenter"
901-
Grid.Column="1"
902903
Margin="0,9,0,10"
903904
VerticalAlignment="Center"
904905
win:HighContrastAdjustment="None"
@@ -908,23 +909,23 @@
908909
ContentTransitions="{TemplateBinding ContentTransitions}"
909910
FontWeight="{TemplateBinding FontWeight}"
910911
Foreground="{TemplateBinding Foreground}" />
911-
<Rectangle x:Name="PART_Pill"
912-
Grid.Column="1"
913-
Width="4"
914-
Height="3"
915-
HorizontalAlignment="Center"
916-
VerticalAlignment="Bottom"
917-
Fill="{ThemeResource PivotItemPillBackground}"
918-
Opacity="0"
919-
RadiusX="0.5"
920-
RadiusY="1"
921-
RenderTransformOrigin="0.5, 0.5">
922-
<Rectangle.RenderTransform>
923-
<CompositeTransform x:Name="PillTransform"
924-
ScaleX="1" />
925-
</Rectangle.RenderTransform>
926-
</Rectangle>
927-
</Grid>
912+
913+
</StackPanel>
914+
<Rectangle x:Name="PART_Pill"
915+
Width="4"
916+
Height="3"
917+
HorizontalAlignment="Center"
918+
VerticalAlignment="Bottom"
919+
Fill="{ThemeResource PivotItemPillBackground}"
920+
Opacity="0"
921+
RadiusX="0.5"
922+
RadiusY="1"
923+
RenderTransformOrigin="0.5, 1">
924+
<Rectangle.RenderTransform>
925+
<CompositeTransform x:Name="PillTransform"
926+
ScaleX="1" />
927+
</Rectangle.RenderTransform>
928+
</Rectangle>
928929
</Grid>
929930
</ControlTemplate>
930931
</Setter.Value>

0 commit comments

Comments
 (0)