在自定义消息框中显示两个文本框?

5

我想在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 !",
            };

1
当您将文本框添加到文本框时,您期望得到什么?富文本框?这个操作是不允许的。另外,请向我们展示Content(类型)和CustomMessageBox的定义。 - Adriaan Stander
我需要获取用户的输入。我需要在 MessageBox 中有两个输入字段。 - Mohamed Thaufeeq
你能展示一下 CustomMessageBox 的实现吗?Content 是什么? - Damith
我已经从这里安装了NuGet,并且正在使用其中的customMessageBox。 - Mohamed Thaufeeq
2个回答

6
使用一个“容器控件”来容纳两个“文本框”。
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
如果你想显示文本,那么:
Content = soora.Text + ayath.Text,

我需要获取用户输入。我需要在消息框中有两个输入字段。 - Mohamed Thaufeeq

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接