WPF图标:矢量图
1.先把矢量图资源加载到窗体资源内
<Window.Resources>
<Style x:Key="PathSource" TargetType="Path">
<Setter Property="Stretch" Value="Fill"/>
<Setter Property="Fill" Value="White"/>
</Style>
<Style TargetType="Path" BasedOn="{StaticResource PathSource}" x:Key="RightIcon" >
<Setter Property="Data" Value="M514 114.3c-219.9 0-398.8 178.9-398.8
398.8 0 220 178.9 398.9 398.8 398.9s398.8-178.9
398.8-398.9c0-219.8-178.9-398.8-398.8-398.8z m232.1 440.4L582
718.8c-22.9 22.9-60.2 22.9-83.1 0-11.5-11.5-17.2-26.5-17.2-41.5s5.7-30.1
17.2-41.5l63.8-63.8H334c-32.5 0-58.8-26.3-58.8-58.8s26.3-58.8
58.8-58.8h228.7l-63.8-63.8c-22.9-22.9-22.9-60.2 0-83.1 22.9-22.9
60.2-22.9 83.1 0l164.1 164.1c22.9 23 22.9 60.2 0
83.1z"></Setter>
</Style>
</Window.Resources>
2.调用
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Style="{StaticResource RightIcon}" Fill="Teal" Margin="2"
Height="40" Width="40" RenderTransformOrigin="0.5,0.5" >
</Path>
<TextBlock Grid.Column="0" VerticalAlignment="Bottom" Margin="5" FontSize="16"> 右</TextBlock>
</WrapPanel>
效果:
同时若要将图标进行旋转可以如下操作:
<WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Style="{StaticResource RightIcon}" Fill="Teal" Margin="2"
Height="40" Width="40" RenderTransformOrigin="0.5,0.5" >
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="180"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
<TextBlock Grid.Column="0" VerticalAlignment="Bottom" Margin="5" FontSize="16"> 左</TextBlock>
</WrapPanel>
原文地址:https://www.cnblogs.com/leoou412/p/12321379.html