1

Hello fellow programmers.

I have a question, that can I change imageBrush ImageSource? If I can, then how does it do that, I have tried many options and none of them seems not to work.

<Path x:Name="PathImage">
    <Path.Fill>
        <ImageBrush ImageSource="pic1.png"/>
    </Path.Fill> 
</Path>
Harshana Narangoda
  • 775
  • 1
  • 8
  • 23
Taurib
  • 451
  • 9
  • 26
  • Try this: http://stackoverflow.com/questions/13756909/can-you-bind-to-the-imagesource-property-of-an-imagebrush-with-caliburn-micro-w – David Apr 26 '14 at 15:18

1 Answers1

0

You can access the ImageBrush by casting the Path's Fill property:

var imageBrush = PathImage.Fill as ImageBrush;
imageBrush.ImageSource = new BitmapImage(new Uri());

Even simpler would be to set the x:Name property directly on the ImageBrush:

<Path x:Name="PathImage">
    <Path.Fill>
        <ImageBrush x:Name="imageBrush" ImageSource="pic1.png"/>
    </Path.Fill> 
</Path>

Now the XAML parser creates a public field that you can access in code behind:

imageBrush.ImageSource = new BitmapImage(new Uri());
Clemens
  • 123,504
  • 12
  • 155
  • 268