在customMessageBox中显示两个文本框?

时间:2013-08-14 05:40:55

标签: c# messagebox

好吧,我想在customMessageBox旁边的下一个旁边显示两个文本框。所以我编写了两个文本框。如下。我为它命名了sooraayath。但在customMessageBox中,我不能同时调用两个文本框。它显示错误。如何在customMessageBox中显示下一个旁边的两个文本框。我只是错误,它是Content = soora + ayath

形式

我的C#代码;

TextBox soora = new TextBox();
                soora.Height = 72;
                soora.Width = 150;
                soora.MaxLength = 3;

TextBox ayath = new TextBox();
                ayath.Height = 72;
                ayath.Width = 150;
                ayath.MaxLength = 3;

CustomMessageBox messageBox = new CustomMessageBox()
            {
                Title = "GO TO",
                Content = soora + ayath,
                RightButtonContent = "Go !",
            };

2 个答案:

答案 0 :(得分:6)

使用container control同时保留textboxes

TextBox soora = new TextBox();
                soora.Height = 72;
                soora.Width = 150;
                soora.MaxLength = 3;

TextBox ayath = new TextBox();
                ayath.Height = 72;
                ayath.Width = 150;
                ayath.MaxLength = 3;

StackPanel container = new StackPanel{
                           Orientation = System.Windows.Controls.Orientation.Horizontal
                       };

container.Children.Add(soora);
container.Children.Add(ayath);    

CustomMessageBox messageBox = new CustomMessageBox()
            {
                Title = "GO TO",
                Content = container,
                RightButtonContent = "Go !",
            };

答案 1 :(得分:1)

如果你想显示文字,那么

Content = soora.Text + ayath.Text,