Skip to content

Commit

Permalink
improve ControlTemplate
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Nov 1, 2024
1 parent 74f14d4 commit 8d39f3e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/IconPacks.Avalonia.Core/PackIconControlBase.xaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:iconPacks="urn:iconpacks-avalonia"
xmlns:converter="clr-namespace:IconPacks.Avalonia.Converter;assembly=IconPacks.Avalonia.Core"
x:ClassModifier="internal">

<ControlTemplate x:Key="IconPacks.Avalonia.PackIconControlBase.Template" TargetType="iconPacks:PackIconControlBase">
<Grid>
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<Grid x:Name="PART_InnerGrid"
Margin="{TemplateBinding BorderThickness}">
<Viewbox x:Name="PART_ViewBox"
Margin="{TemplateBinding Padding}">
<Border CornerRadius="{TemplateBinding CornerRadius}"
ClipToBounds="{TemplateBinding ClipToBounds}"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid x:Name="PART_InnerGrid">
<Viewbox x:Name="PART_ViewBox">
<Path x:Name="PART_IconPath"
Data="{Binding Data, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay, Converter={x:Static converter:NullToDoNothingValueConverter.Instance}}"
Fill="{TemplateBinding Foreground}"
Data="{TemplateBinding Data}"
Stretch="Uniform"
UseLayoutRounding="False" />
</Viewbox>
</Grid>
</Grid>
</Border>
</ControlTemplate>

<ControlTheme x:Key="IconPacks.Avalonia.PackIconControlBase.Theme" TargetType="iconPacks:PackIconControlBase">
<Setter Property="Height" Value="{DynamicResource IconElementThemeHeight}" />
<Setter Property="Width" Value="{DynamicResource IconElementThemeWidth}" />
<Setter Property="ClipToBounds" Value="True" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="Padding" Value="0" />
Expand Down

0 comments on commit 8d39f3e

Please sign in to comment.