How to change any shape (ex rectangle ...) Fill using Inline IF

34 Views Asked by At

I try this code bellow, but without any result, could you please tell my why? I have a rectangle shape in WPF C#, which’s filled with an imagebrush as you see, and I used inline if, but it doesn’t worked as I planed…

Rec1.Fill = Rec1.Fill == (new ImageBrush(new BitmapImage(new Uri(@”C:\1.png”, UriKind.Relative)))
    ? (new ImageBrush(new BitmapImage(new Uri(@”C:\2.png”, UriKind.Relative)))
    : (new ImageBrush(new BitmapImage(new Uri(@”C:\1.png”, UriKind.Relative)));

Note that: Rec1 is my Rectangle; ImageBrush source is 1.png and I want it to be changed to 2.png That’s all I want… but it doesn’t worked.. could you please tell me why?

0

There are 0 best solutions below