在 Avalonia 的 axaml 中定义 string 字符串

在 Avalonia 的 axaml 中定义 string 字符串

一、效果

image

二、代码

    <Window.Resources>
        <x:String x:Key="test_key">字符串字符串字符串字符串字符串</x:String>
    </Window.Resources>


    <Grid>
        <TextBlock
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Text="{StaticResource test_key}" />
    </Grid>

三、总结

类型需要使用 x:String,注意不是小写开头的 x:string,也不是没有 x 开头的 stringString

posted @ 2025-07-09 15:24  fanbal  阅读(49)  评论(0)    收藏  举报