我需要为我的应用程序创建一个图像按钮,如面向web的样式。
我有一个20×20像素的图像,并且想要具有与图像相同尺寸的图像按钮。
我有一个20×20像素的图像,并且想要具有与图像相同尺寸的图像按钮。
我试图将它设置在我的xaml内,但它不起作用:
<Button Grid.Row="0" Margin="0" Padding="0" Click="AddtoFavorite_Click" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right"> <Button.Content> <Image Source="/MyNamespace;component/images/star_yellow.png" Margin="0" Width="20" Height="20" /> </Button.Content> </Button>
哪里不对?
解
我发现最好的解决办法是:
<Image Source="/MyNamespace;component/images/star_yellow.png" ManipulationStarted="Image_ManipulationStarted" Width="20" Height="20"></Image>
谢谢大家!
我的代码中没有看到特定的错误,但是现在我没有工具来测试它,看看它为什么失败。
但是,您可以使用您的图像创建一个VisualBrush,并将其用作Button的背景:
<Button> <Button.Background> <ImageBrush ImageSource="xyz.png"/> </Button.Background> </Button>
大多数背景是Brush类型,所以您可以使用SolidColorBrush,LinearGradientBrush,ImageBrush等。您不限于颜色。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。