Skip to content

Commit

Permalink
Allow icons in Pivot
Browse files Browse the repository at this point in the history
  • Loading branch information
NotYoojun committed Apr 17, 2024
1 parent 0008469 commit cb2bd53
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
3 changes: 2 additions & 1 deletion sample/ExamplePhotoTaker/ExamplePhotoTaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.27" />
<ProjectReference Include="..\..\source\iNKORE.UI.WPF.Modern.Controls\iNKORE.UI.WPF.Modern.Controls.csproj" />
<ProjectReference Include="..\..\source\Inkore.UI.WPF.Modern\iNKORE.UI.WPF.Modern.csproj" />
</ItemGroup>

</Project>
28 changes: 11 additions & 17 deletions sample/ExamplePhotoTaker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@
<Border Grid.Row="1" Margin="10,0,10,10" Background="LightGray" BorderBrush="DimGray" Padding="10" BorderThickness="1">
<Viewbox>
<Viewbox x:Name="Viewbox_Viewport" Width="960">
<Border Background="White" Width="640" Height="320">
<TabControl Margin="10" Style="{StaticResource {x:Static ui:ThemeKeys.TabControlPivotStyleKey}}">
<Border Background="White" Padding="10" Width="640" Height="320">
<TabControl Style="{StaticResource {x:Static ui:ThemeKeys.TabControlPivotStyleKey}}" >

<TabItem>
<TabItem.Header>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="10" TextElement.FontSize="20">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Shop}"/>
<TextBlock Text="TabItem 1"/>
</ui:SimpleStackPanel>
</TabItem.Header>
<TextBlock Text="Content 1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TabItem Header="TabItem 1">
<ui:TabItemHelper.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Shop}" FontSize="20"/>
</ui:TabItemHelper.Icon>
<TextBlock Text="Content 1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</TabItem>

<TabItem>
<TabItem.Header>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="10" TextElement.FontSize="20">
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}"/>
<TextBlock Text="TabItem 2"/>
</ui:SimpleStackPanel>
</TabItem.Header>
<TabItem Header="TabItem 2">
<ui:TabItemHelper.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Settings}" FontSize="20"/>
</ui:TabItemHelper.Icon>
<TextBlock Text="Content 2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</TabItem>

Expand Down
54 changes: 36 additions & 18 deletions source/iNKORE.UI.WPF.Modern/Themes/Styles/Pivot.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<Setter Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselected}" />
<Setter Property="Padding" Value="{DynamicResource PivotHeaderItemMargin}" />
<Setter Property="Height" Value="48" />
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselected}"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
Expand All @@ -31,22 +30,37 @@
<ControlTemplate TargetType="TabItem">
<Border
x:Name="Border"
TextElement.Foreground="{DynamicResource PivotHeaderItemForegroundUnselected}"
Padding="{TemplateBinding Padding}"
chelper:PressHelper.IsEnabled="True"
Background="{TemplateBinding Background}"
SnapsToDevicePixels="True">
<Grid>
<local:ContentPresenterEx
x:Name="ContentPresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
ContentSource="Header"
Focusable="False"
FontFamily="{DynamicResource PivotHeaderItemFontFamily}"
FontSize="{DynamicResource PivotHeaderItemFontSize}"
FontWeight="{DynamicResource PivotHeaderItemThemeFontWeight}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<local:SimpleStackPanel x:Name="SimpleStackPanel_Header" Orientation="Horizontal" Spacing="8">

<local:ContentPresenterEx
x:Name="ContentPresenter_Icon"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding chelper:TabItemHelper.Icon}"
Focusable="False"
FontFamily="{DynamicResource PivotHeaderItemFontFamily}"
FontSize="{DynamicResource PivotHeaderItemFontSize}"
FontWeight="{DynamicResource PivotHeaderItemThemeFontWeight}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<local:ContentPresenterEx
x:Name="ContentPresenter"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
ContentSource="Header"
Focusable="False"
FontFamily="{DynamicResource PivotHeaderItemFontFamily}"
FontSize="{DynamicResource PivotHeaderItemFontSize}"
FontWeight="{DynamicResource PivotHeaderItemThemeFontWeight}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</local:SimpleStackPanel>
<Rectangle
x:Name="SelectedPipe"
Height="3"
Expand Down Expand Up @@ -121,7 +135,7 @@
<Condition SourceName="Border" Property="IsMouseOver" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1" />
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelected}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelected}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelected}" />
</MultiTrigger>
<!-- UnselectedPointerOver -->
Expand All @@ -130,7 +144,7 @@
<Condition Property="IsSelected" Value="False" />
<Condition SourceName="Border" Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPointerOver}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPointerOver}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPointerOver}" />
</MultiTrigger>
<!-- SelectedPointerOver -->
Expand All @@ -140,11 +154,11 @@
<Condition SourceName="Border" Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Panel.ZIndex" Value="1" />
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPointerOver}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPointerOver}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPointerOver}" />
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundDisabled}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundDisabled}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundDisabled}" />
<Setter TargetName="SelectedPipe" Property="Visibility" Value="Collapsed" />
</Trigger>
Expand All @@ -154,7 +168,7 @@
<Condition Property="IsSelected" Value="False" />
<Condition SourceName="Border" Property="chelper:PressHelper.IsPressed" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPressed}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundUnselectedPressed}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundUnselectedPressed}" />
</MultiTrigger>
<!-- SelectedPressed -->
Expand All @@ -163,9 +177,13 @@
<Condition Property="IsSelected" Value="True" />
<Condition SourceName="Border" Property="chelper:PressHelper.IsPressed" Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPressed}" />
<Setter TargetName="Border" Property="TextElement.Foreground" Value="{DynamicResource PivotHeaderItemForegroundSelectedPressed}" />
<Setter TargetName="Border" Property="Background" Value="{DynamicResource PivotHeaderItemBackgroundSelectedPressed}" />
</MultiTrigger>

<Trigger Property="chelper:TabItemHelper.Icon" Value="{x:Null}">
<Setter TargetName="SimpleStackPanel_Header" Property="Spacing" Value="0"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down

0 comments on commit cb2bd53

Please sign in to comment.