You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
3.2 KiB

  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:bpa="clr-namespace:BPA.UIControl"
  4. xmlns:converter="clr-namespace:BPA.UIControl.Converters">
  5. <ResourceDictionary.MergedDictionaries>
  6. <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Resources/Default.xaml" />
  7. </ResourceDictionary.MergedDictionaries>
  8. <!-- Converter -->
  9. <converter:GetCanvasCentreConverter x:Key="getCanvasCentre" />
  10. <Style TargetType="{x:Type bpa:Icon}">
  11. <Setter Property="FlowDirection" Value="LeftToRight" />
  12. <Setter Property="HorizontalAlignment" Value="Center" />
  13. <Setter Property="VerticalAlignment" Value="Center" />
  14. <Setter Property="IsTabStop" Value="False" />
  15. <Setter Property="Width">
  16. <Setter.Value>
  17. <MultiBinding Converter="{StaticResource MathAddConverter}">
  18. <Binding Path="FontSize" RelativeSource="{RelativeSource Self}" />
  19. <Binding Source="6" />
  20. </MultiBinding>
  21. </Setter.Value>
  22. </Setter>
  23. <Setter Property="Height" Value="{Binding Width, RelativeSource={RelativeSource Self}}" />
  24. <Setter Property="Template">
  25. <Setter.Value>
  26. <ControlTemplate TargetType="{x:Type bpa:Icon}">
  27. <Border Background="{TemplateBinding Background}"
  28. BorderBrush="{TemplateBinding BorderBrush}"
  29. BorderThickness="{TemplateBinding BorderThickness}">
  30. <Viewbox>
  31. <Canvas x:Name="canvas"
  32. Width="26"
  33. Height="26">
  34. <Path x:Name="icon"
  35. Data="{Binding Code, RelativeSource={RelativeSource TemplatedParent}}"
  36. Fill="{TemplateBinding Foreground}"
  37. Stretch="Uniform">
  38. <Canvas.Right>
  39. <MultiBinding Converter="{StaticResource getCanvasCentre}">
  40. <Binding ElementName="canvas" Path="ActualWidth" />
  41. <Binding ElementName="icon" Path="ActualWidth" />
  42. </MultiBinding>
  43. </Canvas.Right>
  44. <Canvas.Top>
  45. <MultiBinding Converter="{StaticResource getCanvasCentre}">
  46. <Binding ElementName="canvas" Path="ActualHeight" />
  47. <Binding ElementName="icon" Path="ActualHeight" />
  48. </MultiBinding>
  49. </Canvas.Top>
  50. </Path>
  51. </Canvas>
  52. </Viewbox>
  53. </Border>
  54. </ControlTemplate>
  55. </Setter.Value>
  56. </Setter>
  57. </Style>
  58. </ResourceDictionary>