本帖最后由 m6830098 于 2013-08-09 09:53:23 编辑

解决方案 »

  1.   

    你可以在图片点击事件里面修改Imagebutoon的Source属性来修改图片
      

  2.   

    Source属性如何修改呢。直接用地址还是??  我直接修改了属性。但是。运行的时候,图片就没了。显示不出来了
      

  3.   

    问题是如何修改呢,求指教。
    SOURCE值填写为URI就行了
      

  4.   

    问题是如何修改呢,求指教。
    SOURCE值填写为URI就行了
    ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
    我这样使用的,但是 运行的时候,图片显示不出来是什么原因
      

  5.   

    问题是如何修改呢,求指教。
    SOURCE值填写为URI就行了
    ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
    我这样使用的,但是 运行的时候,图片显示不出来是什么原因
    "Resources\\savefail.png"改成@"Resources/savefail.png"试试
      

  6.   

    问题是如何修改呢,求指教。
    SOURCE值填写为URI就行了
    ButtonSend.Source = new BitmapImage(new Uri("Resources\\savefail.png", UriKind.Relative));
    我这样使用的,但是 运行的时候,图片显示不出来是什么原因
    "Resources\\savefail.png"改成@"Resources/savefail.png"试试

    还是不行,执行了这句图片就不显示了。
      

  7.   

    类似这样
    this.myImage.Source = new BitmapImage(new Uri("Images/Untitled.png", UriKind.Relative));
    代码没什么问题,估计是你把路径搞错了。
      

  8.   

    路径看了下,应该也是没有什么问题的。不知道什么原因。是ImageButton 不能在代码中这样修改source吗。
      

  9.   

    <Image VerticalAlignment="Top"  Height="36" Width="36" Source="{TemplateBinding Source}"/>
    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}}}"/>
      

  10.   

    <Image VerticalAlignment="Top"  Height="36" Width="36" Source="{Binding ImgSource, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageButton}}}"/>
      

  11.   


    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));
     
        }
      

  12.   

    Source="{TemplateBinding Source}你这个无效的绑定,Button本身没有Source属性,在模板里不能用TemplateBinding 来绑定
    用Source="{Binding Source, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageButton}}}" 来绑定
      

  13.   

    <Image VerticalAlignment="Top"  Height="36" Width="36" Source="{TemplateBinding Source}"/>看到这句代码没有,绑定到了Source属性,代码中修改Source属性的时候,实际上就是这个图片控件在变化
      

  14.   

    重写Button还不如直接用RibbonButton+样式