您好,我正在使用 MVVM 开发 WPF 应用程序,我正在尝试将图像添加为按钮(如 Windows 8 起始页按钮)有没有办法让按钮仅显示为图像?我有一个我想单独用作按钮的图像,但我似乎无法让按钮边框消失并且按钮背景颜色变得透明。或以任何方式将图像用作按钮?帮帮我
<Button Style="{StaticResource RoundCorner}" Grid.Column="4" Grid.Row="2"
x:Name="New" Cursor="Hand" FontWeight="ExtraBold"
Margin="10,22,102,5" Grid.RowSpan="4" Grid.ColumnSpan="2">
<Image Source="pack://siteoforigin:,,,/Resources/NewIcon.png"
RenderOptions.BitmapScalingMode="HighQuality" Width="145" Height="93" />
</Button>
最佳答案
您可以将默认的 Button ControlTemplate
替换为普通的 Image
控件。试试这个:
<Button Click="Button_Click" Width="16" Height="16">
<Button.Template>
<ControlTemplate>
<Image Stretch="None"
Source="pack://application:,,,/AppName;component/FolderName/ImageName.png" />
</ControlTemplate>
</Button.Template>
</Button>
关于css - 如何添加wpf图像按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25846421/