我在后台定义了静态变量
public partial class XStatic : Window
{
public static string title = "wo de title";
public XStatic()
{
InitializeComponent();
}
}
xmal中使用x:static获取他
<StackPanel>
<TextBox Text="{x:Static local:XStatic.title}"/>
</StackPanel>
我的命名空间也是引入进来了
x:Class="X命名空间详解.XStatic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:X命名空间详解"
mc:Ignorable="d"
但是他为什么一直报错,无法获取。