【发布时间】:2010-11-29 10:21:57
【问题描述】:
我需要为我的应用程序创建一个图像按钮,例如面向 Web 的样式。 我有一个 20x20 像素的图像,并且想要一个与图像尺寸相同的图像按钮。
我试图在我的 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>
谢谢大家!
【问题讨论】:
-
我认为这个解决方案存在缺陷。问题是如果有人从您的按钮开始滑动视图,通常按钮单击不会注册。无论您实现它的方式如何,该按钮都将被视为已单击。这与用户期望手机工作的方式有悖常理,并可能导致混乱的用户体验。我认为您最好使用按钮,但将其设置为呈现为图像。
标签: windows-phone-7 imagebutton