1 回答

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊
您可以將 MainWindow 對(duì)象傳遞給程序類并更改您想要的值
public partial class MainWindow : Window, ICommon
{
public MainWindow()
{
InitializeComponent();
Program test = new Program();
thisButton.Click += delegate(object sender, RoutedEventArgs e) { test.WhenPressed_1(this); };
}
public void SetValueInMain()
{
// Set Main values
}
public class Program
{
public string Word { get; set; }
public void WhenPressed_1(ICommon mainWind)
{
mainWind.SetValueInMain();
}
}
}
public interface ICommon
{
void SetValueInMain();
}
- 1 回答
- 0 關(guān)注
- 78 瀏覽
添加回答
舉報(bào)