x:Static

作者: Lulus | 来源:发表于2017-12-30 19:16 被阅读0次

用途:访问代码中的变量等

后台定义一个变量

public partial class GetStaticFromBackgroundCode : Window
{
    public static string Name = "这是来自后台的静态变量";
    public GetStaticFromBackgroundCode()
    {
        InitializeComponent();
    }
}

前端访问

<TextBox Text="{x:Static local:GetStaticFromBackgroundCode.Name}"></TextBox>

示例代码

https://github.com/zLulus/NotePractice/tree/dev3/WPF/WpfDemo/GetStaticFromBackgroundCode

相关文章

网友评论

      本文标题:x:Static

      本文链接:https://www.haomeiwen.com/subject/lfjngxtx.html