简体   繁体   English

如何在我的XAML 2017 VS程序中添加图标

[英]How to add an icon to my xaml 2017 VS programme

I want to add an icon to my button. 我想在按钮上添加一个图标。

 <Button Name="btnPlay"
         HorizontalAlignment="Stretch"
         Content="Play"
         Margin="10"
         VerticalAlignment="Top"
         Click="btnPlay_Click">
    <Button.Icon>
      <Image Source="play icon.png" />
    </Button.Icon>
</Button>

This is my current code but it does not seem to be working. 这是我当前的代码,但似乎没有用。 Please help me. 请帮我。 Thank you! 谢谢!

The Button control has no Icon property in UWP. 在UWP中, Button控件没有Icon属性。 If you want to show image in Button's content, you could custom its content like the following: 如果要在Button的内容中显示图像,可以自定义其内容,如下所示:

<Button Name="btnPlay"
     HorizontalAlignment="Stretch"
     Margin="10"
     VerticalAlignment="Top"
     Click="BtnPlay_Click">
        <Button.Content>
            <StackPanel Orientation="Horizontal">
                <Image Source="/Assets/play.png"  Width="30" Height="20"/>
                <TextBlock Text="Play"></TextBlock>
            </StackPanel>
        </Button.Content>
</Button>

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM