gpt4 book ai didi

用于将资源包含为 xml 元素而不是属性的 WPF XAML 语法

转载 作者:行者123 更新时间:2023-12-04 09:43:00 28 4
gpt4 key购买 nike

我有这个工作:

    <Button Content="{StaticResource SaveImage}" />

但现在我想让按钮更复杂一点
        <Button>
<Button.Content>
<StackPanel Orientation="Horizontal" >
{StaticResource SaveImage} <!-- WHAT GOES HERE?? -->
<Label>Save</Label>
</StackPanel>
</Button.Content>
</Button>

如何将图像资源放置在 xml 树中,而不是仅将其分配给 Button 类的属性?

请注意,资源定义如下:
<Image x:Key="SaveImage" x:Shared="False" Source="Save.png" Height="16" Width="16"/>

最佳答案

您可以使用 StaticResource直接地。像这样试试

<Button>
<Button.Content>
<StackPanel Orientation="Horizontal" >
<StaticResource ResourceKey="SaveImage"/>
<Label>Save</Label>
</StackPanel>
</Button.Content>
</Button>

关于用于将资源包含为 xml 元素而不是属性的 WPF XAML 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5117965/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com