I have some XAML to draw a logo and I want to re-use this in various other XAML files (it has no UI and requires no code). The top level of the logo XAML is a Canvas
item.
To use the logo in other XAML files is it best to define this logo as an element in a ResourceDictionary
or create a UserControl
?
This seems easy with a UserControl
, however I want to load my XAML files in with XamlReader so I would prefer to use resources so that these can be specified within the XAML. It seems possible to store items such as a Canvas
in a ResourceDictionary
but I am not sure how to reference them.
For example, I can define my logo as a ResourceDictionary
element as follows:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas x:Name="LayoutRoot" x:Key="Logo">
<!-- My Logo -->
</Canvas>
</ResourceDictionary>
But how can I use this Logo
in my other XAML files - maybe I have got the wrong idea about resources?