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

效果圖 :

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM