WPF 中组合框上的文本框
<Grid>
<ComboBox Name="comboBox1" />
<TextBox Name="TextBox1" />
</Grid>
在我的 wpf 应用程序中,我想在组合框上显示一个文本框,但我不知道如何维护文本框大小,以便它只覆盖组合框的框部分,而不覆盖组合框的向下箭头部分?
<Grid>
<ComboBox Name="comboBox1" />
<TextBox Name="TextBox1" />
</Grid>
In my wpf application I want to display a textbox on a combobox but i don't know how to maintain textbox size so that it only covers the box part of the combobox and not the down arrow part of combobox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样做:
关键是将网格的第二列设置为固定大小,其中该固定大小表示箭头的可见性。
不过,就像其他人提到的那样,最好的办法是将组合框的 IsEditable 属性设置为 true:
有关详细信息,请参阅此处:WPF 组合框 - 可编辑
You can do it like:
The key thing is to set the grid's second column to a fixed size, where that fixed sized represents the visibility of the arrow.
though, like others have mentioned, the best thing to do is set the combobox's IsEditable property to true:
for more info, see here: WPF ComboBox - IsEditable
我认为没有充分的理由将文本框放置在组合框上,因为组合框本身是可编辑的。
但您可以做的是,将组合框分成两个网格列,后面的列固定大小,包括组合框的箭头部分,前一列星形大小。让组合框的列跨度为 2,文本框为 1。
希望有帮助
I don't see a good reason to place a textbox over a combobox, as combobox itself is editable.
But what you can do is, divide your combobox in two gridcolums with later column being fixed sized includeing the arrow part of combobox and former column being star sized. Let combobox have columnspan of 2 and textbox of 1.
hope it helps