0

我已经创建了一个这样的 CustomMessageBox:

 TextBox tbName = new TextBox();
            tbName.Text = "test";
            tbName.Name = "tbName";

                Grid grid = new Grid();
                grid.Children.Add(tbName);
                grid.Name = "grid";
                CustomMessageBox mb = new CustomMessageBox()
                {
                    Caption = "test",
                    Message = "message",
                    Content = grid,
                    LeftButtonContent = "ok",
                    RightButtonContent = "cancel"
                };
                mb.Dismissed += (e1, e2) =>
                {
                  //how to get textbox text ?
                };
                mb.Show();

我想检索文本框内容,我该怎么做?

谢谢

4

1 回答 1

2

您已经有了对 TextBox 的引用,那么问题出在哪里?

mb.Dismissed += (e1, e2) =>
{
    System.Diagnostics.Debug.WriteLine(tbName.Text);
};
于 2013-06-19T13:26:52.740 回答