我想为按钮设置图像,我的图像不包含其中的文本,我想手动设置该图像的文本,我试过这种方式按钮与图像的按钮的内容,但我DONO如何为它设置的文字,我在Visual Studio 2012的工作为Windows Mobile 7如何设置图像内容为一个按钮为Windows Phone 7
0
A
回答
0
<Button x:Name="ButtonName" Height="Auto" Width="Auto">
<StackPanel>
<Image Source=image.JPG" Stretch="Fill" Height="Auto" Width="Auto" />
<TextBlock Text="picture Button" TextAlignment="Center" />
</StackPanel>
</Button>
事情是DONOT设置按钮的内容属性。 也给予适当大小的按钮,否则图像控制将使其过分大
把你的控件通过按钮的支持,可以采取很多的孩子,而不是只有一个孩子的StackPanel里面,你可以更容易地控制规模。
根据你给的图片,这里是我的代码。你也应该把这个图像链接在你的问题
<Button Content="Text" Height="Auto" Width="Auto" BorderThickness="0">
<Button.Background>
<LinearGradientBrush StartPoint="0 0" EndPoint="0 1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Offset="0" Color="#FF03CCF0" />
<GradientStop Offset="1" Color="#FF0182C2" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Button.Background>
</Button>
根据要求更改按钮的大小。另外,您可能需要使用VisualStateManager更改其他视觉状态的背景,但结果会更清晰。也有非常肮脏的伎俩。我不会为它发布代码。 使用画布作为内容,设置其背景,然后在里面插入文本块。我不知道这项工作,但我不会这样做。建议使用VisualStateManager。
0
图像充当按钮的最简单方法是设置样式属性。
<Style x:Key="CustomButton" TargetType="Button">
<Setter Property="Template" >
<Setter.Value >
<ControlTemplate>
<Image Source="Images/Sample.jpg" />
</ControlTemplate >
</Setter.Value >
</Setter >
通过定义一个新的块<Grid.Resources></Grid.Resources>
或者你可以做到这一点普遍在StandardStyles.xaml
,当你定义一个新的按钮设置BasedOn
属性的项值设置在您的网页此代码你已经定义了风格。
相关问题
- 1. 如何在Windows Phone 7中设置按钮的点击图像?
- 2. Windows Phone 7-将图像源设置为内存中的流
- 3. 设置图像为禁用按钮在Windows Phone 8
- 4. 带图像的Windows Phone 7按钮
- 5. Windows Phone图像作为按钮
- 6. Windows Phone 7未设置图像
- 7. Windows Phone 7按钮
- 8. 如何为windows phone 7应用程序设置背景图片
- 9. 将内容描述设置为图像按钮的问题
- 10. Windows Phone 7设置
- 11. 通过Windows Phone中的代码访问按钮内容(这是一个图像)
- 12. 为Windows Phone 7
- 13. 按钮颜色-Windows Phone 7
- 14. Windows Phone 7按钮状态
- 15. Windows phone 7按钮“边框”
- 16. 如何将位图图像转换为Windows Phone 7中的png?
- 17. 为图片内容设置切换按钮的快捷键
- 18. WrapPanel为Windows Phone 7
- 19. 如何将图像转换为Windows Phone 7中的视频
- 20. 如何将图像转换为Windows Phone 7中的字节流?
- 21. 如何将位图图像设置为按钮背景图片
- 22. Windows Phone 7内置声音
- 23. 如何将图像类的图像源设置为MapIcon Windows Phone 8.1
- 24. 如何从Windows Phone 7设备向Facebook发布内容
- 25. 如何在Bootstrap 4中将按钮设置为一个按钮?
- 26. 背景图像Windows Phone 7
- 27. 使用WriteableBitMapExWPhone将WriteableBitmap图像设置为windows phone 7中的背景
- 28. 编辑一个滑块的拇指模板成为一个图像Windows Phone 7
- 29. 集图像作为Windows Phone的提醒内容8
- 30. 在windows phone 7中按下时如何设置stackpanel的背景?
非常感谢你..它的工作现在很好 – lokesh
然后如何检查它作为答案。它会取得我的分数,并将在未来对其他人有用。 –
sry它不工作,我不能设置图像内容,通过使用上面的代码我可以做更多没有按钮。的控件,但我需要设置该图像的内容或文本,我有图像与空的内容我怎么能实现这一目标? – lokesh