解决方案 »
- 关于委托的问题
- 正则提取图片路径。
- 100分 在线等 准备学习CMMI 之类的,求过来人推荐
- 用本类的构造方法创建对象 与 用其他类的普通方法创建的对象 有什么区别?
- 一个正则表达式 知道的麻烦说一下 没几分了
- WinForm中,我想要在DataGrid中让用户弹出一个窗口选择,并且读取用户选择的资料,写入到DataGrid中,大家有什么好办法?
- 请教解决大数据量导入的问题(在线等待)
- 下面的c++代码如何转为c#
- win form程序中的问题:如何让程序记住上次运行时的数据,不用数据库,也不写注册表,谢谢!
- 怎么将电脑图片转换成二进制流
- C#中需要添加很多张不同尺寸的图片该如何处理?
- iis上部署一个wcf服务,但是无法访问到终结点
SOURCE值填写为URI就行了
SOURCE值填写为URI就行了
ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
我这样使用的,但是 运行的时候,图片显示不出来是什么原因
SOURCE值填写为URI就行了
ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
我这样使用的,但是 运行的时候,图片显示不出来是什么原因
"Resources\\savefail.png"改成@"Resources/savefail.png"试试
SOURCE值填写为URI就行了
ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
我这样使用的,但是 运行的时候,图片显示不出来是什么原因
"Resources\\savefail.png"改成@"Resources/savefail.png"试试
还是不行,执行了这句图片就不显示了。
this.myImage.Source = new BitmapImage(new Uri("Images/Untitled.png", UriKind.Relative));
代码没什么问题,估计是你把路径搞错了。
Button没有ImageSource属性,你这样绑定怎么能显示,你要设一个属性,
public ImageSource ImgSource {get;set;}
然后
<Image VerticalAlignment="Top" Height="36" Width="36" Source"{Binding ImgSource, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageButton}}}"/>
public class ImageButton : Button
{
// Define an image button user control which is a button with image. A source (can use any name) property is defined to bind to source of inside image control
public ImageSource Source
{
get { return base.GetValue(SourceProperty) as ImageSource; }
set { base.SetValue(SourceProperty, value); }
}
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register("Source", typeof(ImageSource), typeof(ImageButton));
}
用Source="{Binding Source, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageButton}}}" 来绑定