Search code examples
c#imagexamlbitmapbrush

Why don't I see the image in my "Border"?


I'm making a legend inside an XAML file, and I'm using a Border to show what it all looks like. I have three such objects:

<Border x:Name="box_Interior_PalletGroup_Color" Height="20" Width="20" Grid.Row="1" Grid.Column="0">
    <Border.BorderBrush>
        <ImageBrush ImageSource="/Product.Customer.Client;component/Views/views/All_Colours.png" />
    </Border.BorderBrush>
</Border>

<Border x:Name="box_Interior_Brown" Height="20" Width="20" Grid.Row="2" Grid.Column="0" Background="Brown"/>

<Border x:Name="box_Interior_Transparant" Height="20" Width="20" Grid.Row="3" Grid.Column="0">
    <Border.BorderBrush>
        <ImageBrush ImageSource="/Product.Customer.Client;component/Views/views/Transparant.png" />
    </Border.BorderBrush>
</Border>

The images All_Colours.png and Transparant.png have been imported, using the resource editor.

A screenshot concerning All_Colours.png looks as follows:

enter image description here

In the "Properties" window, you can clearly see the All_Colours.png in the BorderBrush property, but in the XAML, there's nothing.

What should I do in order to see the mentioned files All_Colours.png and Transparant.png in the design of my XAML?

By the way, my "Transparant.png" file looks as follows (a mixture of white and grey squares):

enter image description here

If anybody has a better way to show some "transparant", don't hesitate to let me know.


Solution

  • After some searching, I found the answer to be ridiculously easy, as you can see:

    <Border x:Name="box_Interior_PalletGroup_Color" ...>
      <Image Source="/Product.Customer.Client;component/Views/views/Colours.png" />
    </Border>
    
    <Border x:Name="box_Interior_Transparant" ...>
      <Image Source="/Product.Customer.Client;component/Views/views/Transp.png" />
    </Border>