绑定静态评估器 wpf C#

Binding static assessors wpf C#

早上好。

我想用 public 静态评估器将值保存在 class 中。例如:

public class Global
{
     public static string Information { get; set; }
     ...
}

我想从 UI 级别更改这些值。我试过这样做:

<TextBox Text="{Binding Source={x:Static Member=local:Global.Information}}"/>

但是出现错误:

Two-way binding requires Path or XPath.

我一直在寻找答案,但每个解决方案都不适合我。

如何将来自 class 的静态访问器与文本 属性 绑定?

对静态属性使用此 PropertyPath 语法,自 WPF 4.5 起可用:

Text="{Binding Path=(local:Global.Information)}"/>