我有一些带有TextBlock
控件的.xaml文件
<TextBlock Text="........." Name="myTxt" />
我需要在Text
上设置App.xaml.cs中的属性设置值“ Something”
public partial class App : Application
{
public static string something { get; set; }
}
答案 0 :(得分:0)
这应该有效:
<TextBlock xmlns:local="clr-namespace:WpfApp1" Text="{x:Static local:App.something}" Name="myTxt" />
...只要您将“ WpfApp1”更改为App
类的命名空间为:
namespace WpfApp1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static string something { get; set; } = "something...";
}
}