WPF中给Button加上图标和文字

要实现在Button里面加入图标或者图形以及文字,我们就需要在Button里面用一个WrapPanel控件,这个WrapPanel控件会把我们的图标或者文字进行包裹,并显示出来。

Xaml:

        <Button HorizontalAlignment="Left" Margin="222,151,0,0" VerticalAlignment="Top" Width="259" Height="52">
            <WrapPanel Height="52" Width="259">
                <Image Height="52" Width="61" Source="Resources/数据管理.png"/>
                <TextBlock TextWrapping="Wrap" Text="数据管理" Width="197" FontSize="22" VerticalAlignment="Center" Padding="40,0,0,0"/>
            </WrapPanel>
        </Button>

这里面Image的Source是需要你自己添加的图像资源,怎样引入外部的图像资源?看看这个 https://www.cnblogs.com/Leozi/p/10777780.html

效果图 :

原文地址:https://www.cnblogs.com/Leozi/p/10811962.html