如何在 WPF 中制作带有 Button 的 TextBox? [英] How to make a TextBox with a Button inside in WPF?

查看:50
本文介绍了如何在 WPF 中制作带有 Button 的 TextBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个 TextBox,里面有一个 Button,类似于 DatePicker,但不完全是这样.也可以是TextBox里面的ComboBox,这样就可以切换TextBox的模式.

I'd like to make a TextBox with a Button inside, something like a DatePicker, but not exactly. Or can it be a ComboBox inside the TextBox, so you can switch the mode of the TextBox.

你能帮我吗?

推荐答案

如果你想要组合框或日期时间选择器之类的东西,你应该创建一个新控件,在这个新控件中并排放置一个文本框和一个按钮在看起来像文本框框架的框架内 - 然后重新设置文本框的样式,使其没有框架.

If you want something like a combobox or a date time picker you should create a new control, inside this new control place a text box and a button side by side inside a frame that looks like the frame of a textbox - then restyle the textbox so it doesn't have a frame.

如果您想将按钮放在文档"中,但不能很好地替代组合框,那么将按钮放在 Rich Edit 中非常有用.

putting a button inside a rich edit is great if you want to put a button inside a "document" but not a good substitute for a combobox.

请参阅 ComboBox 控件模板 MSDN

See the ComboBox control template MSDN

这篇关于如何在 WPF 中制作带有 Button 的 TextBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆