Binary Resources in WPF

Whether binary resources are added to a Visual Studio project with the Resource build action, linked as loose files with the Content build action, or left as loose files that are not added to the project at all, WPF provides a mechanism for accessing them from code or XAML with a uniform resource identifier (URI). A type converter enables such URIs to be specified in XAML as simple strings with a few built-in shortcuts for common scenarios.

Here’s a simple example of referencing images included in the project:

<StackPanel Orientation="Horizontal">  <Button x:Name="previousButton" ToolTip="Previous (Left Arrow)" ...>    <Image Height="21" Source="previous.gif" />  </Button>  <Button x:Name ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.