WPF 弹窗

效果:

主窗体打开弹窗ModifyTextDialog

private void ModifyTextClick(object sender, RoutedEventArgs e)
{
	ModifyTextDialog dialog = new ModifyTextDialog(myTextBlock.Text);
	var r= dialog.ShowDialog();
        //得到弹窗返回结果,如果是true
	if (r.HasValue && r.Value==true)
	{
		myTextBlock.Text = dialog.myTextBox.Text;
	}
}

窗体事件:

private void OkClick(object sender, RoutedEventArgs e)
{
	//设置结果
	this.DialogResult = true;
	this.Close();
}

private void CancleClick(object sender, RoutedEventArgs e)
{
	this.DialogResult = false;
	this.Close();
}

示例代码

MoveAndResizeControlmove and rezise TextBlock文本框,右键“修改文字内容”

posted @ 2020-04-18 10:53  Lulus  阅读(2560)  评论(0编辑  收藏  举报