加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows Phone 7图像按钮

发布时间:2020-12-13 20:56:14 所属栏目:Windows 来源:网络整理
导读:我需要为我的应用程序创建一个图像按钮,如面向web的样式。 我有一个20×20像素的图像,并且想要具有与图像相同尺寸的图像按钮。 我试图将它设置在我的xaml内,但它不起作用: Button Grid.Row="0" Margin="0" Padding="0" Click="AddtoFavorite_Click" Widt
我需要为我的应用程序创建一个图像按钮,如面向web的样式。
我有一个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等。您不限于颜色。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读