Developing for Modern Windows

Tips, tricks, and guides for developing on modern Windows platforms

BitmapIcon – Use an Image Like an Icon

In Universal Windows Platform Apps you can use BitmapIcon to treat an image as if it’s an icon/text. In my current project I use this feature to colour some white images with transparent backgrounds to match my app’s changeable theme colour.

Here’s a simple example of it in use:


<Button x:Name="MyButton" Foreground="{StaticResource MainColourBrush}" Background="{x:Null}" Tapped="MyButton_Tapped">
    <Button.Content>
        <BitmapIcon UriSource="Images/UI/image.png" Foreground="{StaticResource MainColourBrush}" />
    </Button.Content>
</Button>

That white image will be coloured to match MainColourBrush, just as you can change the colour of text.

Tags:

Leave a Reply

Your email address will not be published.