I've got this working:
    <Button Content="{StaticResource SaveImage}" />
But now I want to make the button a little more complic开发者_如何学Pythonated
        <Button>
            <Button.Content>
                <StackPanel Orientation="Horizontal" >
                    {StaticResource SaveImage} <!-- WHAT GOES HERE?? -->
                    <Label>Save</Label>
                </StackPanel>
            </Button.Content>
        </Button>
How do I place the image resource in the xml tree, rather than just assigning it to a property to the Button class?
Note, the resource is defined like:
<Image x:Key="SaveImage" x:Shared="False" Source="Save.png" Height="16" Width="16"/>
You can use a StaticResource directly. 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 just to use content control inside
<Button>
   <ContentControl Content="{StaticResource whatever}" />
</Button>
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论