【发布时间】:2019-05-31 20:17:44
【问题描述】:
我创建了一个页面并向该页面添加了一个按钮。
我把这个页面放在主窗口的一个框架中。
MainUi.Content = new Page1();
我想在单击按钮时在主窗口中启动一个线程。
在主窗口中
namespace WpfApp3
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void SendMessage()
{
MessageBox.Show("This is a test massage.");
//And more
}
}
页面内
namespace WpfApp3.Pages
{
public partial class Page1: Page
{
public Page1()
{
InitializeComponent();
}
private void SendMessage_Click(object sender, RoutedEventArgs e)
{
SendMessage();
//I want run this thread from here
}
}
}
谢谢。
【问题讨论】: