如何添加背景图片在WPF中单选按钮? [英] How can I add background image to radiobutton in wpf?

查看:282
本文介绍了如何添加背景图片在WPF中单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将图像添加到在WPF动态的单选按钮?这可能吗?


解决方案

  myRadioButton.Content
      =新的图像()
                {
                   来源=
                       (新ImageSourceConverter())。ConvertFrom(
                         图像/ pic.png)作为
                             的ImageSource
                };

这code将加载来自同一装配当地的图片文件夹中的单选按钮图像pic.png。

How can I add an image to the radiobutton in WPF dynamically? is it possible?

解决方案

  myRadioButton.Content
      = new Image()
                {
                   Source =
                       (new ImageSourceConverter()).ConvertFrom(
                         "Images/pic.png") as
                             ImageSource
                }; 

This code will load an image "pic.png" in a radio button from local "Images" folder from same assembly.

这篇关于如何添加背景图片在WPF中单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆