我创建了一个页面,并在该页面上添加了一个按钮。
然后,我将此页面放置在主窗口的框架中。
MainUi.Content = new Page1();
当我点击按钮时,我想在主窗口中启动一个线程。
在MainWindow中
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
}
}
}
感谢。
win
应该是MainWindow
类型。请查看我的编辑。 - mm8