wpf 如何增加 XAML 中 SymbolIcon 的大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25149889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase the size of a SymbolIcon in XAML?
提问by Mike
I have a button that I want to use to launch video playback, so it should look like a "Play" button. The button will be fairly large on screen. This is what I have so far:
我有一个按钮,我想用它来启动视频播放,所以它应该看起来像一个“播放”按钮。该按钮在屏幕上会相当大。这是我到目前为止:
<Button Style="{StaticResource PlayButton}">
<SymbolIcon Symbol="Play"/>
</Button>
The PlayButton resource defines a MinHeight and MinWidth of 200px. The problem with this is that the play icon is very small, in the order of 16px or so. How can I make it larger? I tried setting FontSize="200" in the Button declaration, but it makes no difference.
PlayButton 资源定义了 200px 的 MinHeight 和 MinWidth。这样做的问题是播放图标非常小,大约为 16px 左右。我怎样才能让它变大?我尝试在 Button 声明中设置 FontSize="200",但没有区别。
回答by Mike
Not sure if this is the best way to do it, but it worked for me and might work for you:
不确定这是否是最好的方法,但它对我有用并且可能对你有用:
<Button Style="{StaticResource PlayButton}">
<Viewbox MaxHeight="200" MaxWidth="200">
<SymbolIcon Symbol="Play"/>
</Viewbox>
</Button>
回答by Filip Skakun
You could use a TextBlockwith FontFamily="Segoe UI Symbol" Text=""and then setting FontSizeworks. If you look at the Symbolvalues - you can see the 57602 is the value of the Playsymbol enum which corresponds to the character code in "Segoe UI Symbol". More typically these values are written with their hex values as in Text="", but the decimal is easier to find if you look at that enum's documentation.
您可以使用TextBlockwithFontFamily="Segoe UI Symbol" Text=""然后设置FontSize工作。如果您查看这些Symbol值 - 您可以看到 57602 是Play符号枚举的值,它对应于“Segoe UI Symbol”中的字符代码。更典型的是,这些值是用它们的十六进制值写入的Text="",但如果您查看该枚举的文档,则更容易找到十进制值。
回答by Andrei Schneider
Another easy solution is to use RenderTransform. E.g.
另一个简单的解决方案是使用 RenderTransform。例如
<AppBarButton Icon="Previous" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" >
<AppBarButton.RenderTransform>
<CompositeTransform ScaleX="1.4" ScaleY="1.4"/>
</AppBarButton.RenderTransform>
</AppBarButton>
回答by Максим
<Button.Content>
<TextBlock Style="{StaticResource SymbolTextBlockStyle}"
Text=""/>
</Button.Content>
<Style x:Key="SymbolTextBlockStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
<Setter Property="FontSize" Value="16"/>
</Style>
You can insert the icon as a text block, and change the font size, color and much more
您可以将图标作为文本块插入,并更改字体大小、颜色等

