如何在XAML中增加SymbolIcon的大小?

问题描述 投票:22回答:4

我有一个按钮,我想用它来启动视频播放,所以它应该看起来像一个 "播放 "按钮。这个按钮在屏幕上会相当大。这是我目前所拥有的。

<Button Style="{StaticResource PlayButton}">
    <SymbolIcon Symbol="Play"/>                                
</Button>

PlayButton资源定义了200px的最小高度和最小宽度。这个问题是播放图标非常小,大约16px左右。怎样才能让它变大呢? 我试过在Button声明中设置FontSize="200",但没有任何区别。

wpf xaml windows-store-apps win-universal-app
4个回答
38
投票

不知道这是否是最好的方法 但对我来说是可行的,对你来说也是可行的

<Button Style="{StaticResource PlayButton}">
    <Viewbox MaxHeight="200" MaxWidth="200">
        <SymbolIcon Symbol="Play"/>                                
    </Viewbox>
</Button>

10
投票

你可以用一个 TextBlockFontFamily="Segoe UI Symbol" Text="&#57602;" 然后设定 FontSize 作品。如果你看一下 Symbol 值--你可以看到57602的值是 Play 符号枚举,对应于 "Segoe UI符号 "中的字符代码。更典型的是,这些值与它们的十六进制值一起书写,例如 Text="&#xE102;"但如果你看一下那个枚举的文档,小数点会更容易找到。


6
投票

另一个简单的解决方案是使用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>

0
投票
<Button.Content>
      <TextBlock Style="{StaticResource SymbolTextBlockStyle}"
                 Text="&#xE102;"/>
</Button.Content>

<Style x:Key="SymbolTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
    <Setter Property="FontSize" Value="16"/>
</Style>

你可以将图标作为文本块插入,并改变字体大小、颜色等。

© www.soinside.com 2019 - 2024. All rights reserved.