【发布时间】:2013-11-29 11:20:30
【问题描述】:
我对 WPF 还很陌生,我需要你的帮助来处理一个在多个 WPF 窗口之间传递的对象。
首先,我的 MainWindow 带有 Button_Click 事件,如下所示:
private void Button_Click(object sender, RoutedEventArgs e)
{
Attribute ChooseYourAttr = new Attribute();
Application.Current.MainWindow.Close();
ChooseYourAttr.Show();
Character Player = new Character(firstTextbox.Text);
}
然后我的第二个窗口叫做 Attribute 有这样的东西:
private void attributeTopLabel_Initialized(object sender, EventArgs e)
{
String welcomeAttribute = "Ahh. I see! So ";
attributeTopLabel.Content = welcomeAttribute;
}
我想要这样的东西:(Player.getName());
private void attributeTopLabel_Initialized(object sender, EventArgs e)
{
String welcomeAttribute = "Ahh. I see! So " + Player.getName();
attributeTopLabel.Content = welcomeAttribute;
}
感谢您的回答!
【问题讨论】: