Silverlight – How to create a button with an image and text in F #?

I have a button with the following image:

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

I want the button content to contain some text and images.

I can I did either of these two things well, but they didn’t put my text and pictures on the button at the same time:

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

These do not work:

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

Set the background as an image:

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

Any thoughts / Ideas? Thanks!

You can create a StackPanel and add it together with TextBlock as its children. Then this stack The panel is set as the button content. You can also choose some other panels.

I have a button, the image is as follows:

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

I hope the button content contains some Text, and images.

I can do either of these two things very well, but they didn’t put my text and images on the button at the same time:

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

None of these works:

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

I also can’t set the background of the button as an image:

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

Any thoughts/thoughts? Thanks!

You can create a StackPanel and add it together with TextBlock as its children. Then set this stack panel as the button content. You can also choose some others Panel.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4037 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.