silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了silverlight – 如何在F#中创建包含图像和文本的按钮?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我有一个按钮,图像如下: let btnFoo = new Button() let imgBar = new BitmapImage(new System.Uri("images/whatever.png", System.UriKind.RelativeOrAbsolutE)) 我希望按钮内容包含一些文本,以及图像. 我可以很好地完成这两件事中的任何一件,但他们同时没有把我的文字和图片都拿到按
我有一个按钮,图像如下:

let btnFoo = new Button()
let imgBar = new BitmapImage(new System.Uri("images/whatever.png",System.UriKind.RelativeOrAbsolutE))

我希望按钮内容包含一些文本,以及图像.

我可以很好地完成这两件事中的任何一件,但他们同时没有把我的文字图片都拿到按钮上:

btnFoo.Content <- "Text"
btnFoo.Content <- imgBar

这些都不起作用:

btnFoo.Content <- "Text " + imgBar // compiler hates this
btnFoo.Content <- "Text ",imgBar // compiler is OK,but result is ugly since the image is rendered as the class text

我也无法将按钮的背景设置为图像:

btnFoo.BACkground <- imgBar // compiler doesn't like this because BACkground expects a Media.brush

有什么想法/想法吗?谢谢!

解决方法

可以创建 StackPanel并将其与 TextBlock一起添加为其子项.然后将此堆栈面板设置为按钮内容.您也可以选择其他一些 @L_301_2@.

大佬总结

以上是大佬教程为你收集整理的silverlight – 如何在F#中创建包含图像和文本的按钮?全部内容,希望文章能够帮你解决silverlight – 如何在F#中创建包含图像和文本的按钮?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。