WPF XAML syntax for including a resource as an xml element, not as a property
This works for me:
<Button Content="{StaticResource SaveImage}" /> But now I want to make the button a little harder
<Button> <Button.Content> <StackPanel Orientation="Horizontal" > {StaticResource SaveImage} <!-- WHAT GOES HERE?? --> <Label>Save</Label> </StackPanel> </Button.Content> </Button> How to place an image resource in an xml tree, and not just assign it to a property of the Button class?
Note. A resource is defined as:
<Image x:Key="SaveImage" x:Shared="False" Source="Save.png" Height="16" Width="16"/> You can directly use StaticResource . Try it like this:
<Button> <Button.Content> <StackPanel Orientation="Horizontal" > <StaticResource ResourceKey="SaveImage"/> <Label>Save</Label> </StackPanel> </Button.Content> </Button> <Image Source="{StaticResource SaveImage}"/> The easiest way to go in most of these situations is to simply use content management inside
<Button> <ContentControl Content="{StaticResource whatever}" /> </Button>