WPF:带有进度条的文本框

发布于 2024-08-04 06:02:29 字数 30 浏览 1 评论 0原文

WPF 中是否可以在文本框的背景中嵌入进度条?

Is it possible in WPF to embed a ProgressBar in the Background of a TextBox?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思故 2024-08-11 06:02:29

是的,但是您可以实现不同级别的集成。

最简单的方法是在同一 Grid 中托管具有透明背景的 ProgressBarTextBox

<Grid>
    <ProgressBar/>
    <TextBox Background="#00ffffff"/>
</Grid>

重要的是,背景颜色是透明的,但对命中测试可见。 #00000000 不会按预期工作,因为单击 TextBox 实际上就是单击 ProgressBar

您还可以重新模板化 TextBox 以将 ProgressBar 更本质地合并到其模板中。但是,除非您在使用时编写自己的控件,否则这的用途是有限的。

Yes, but there are varying levels of integration you could achieve.

The simplest way would be to host a ProgressBar and TextBox with see-through background in the same Grid:

<Grid>
    <ProgressBar/>
    <TextBox Background="#00ffffff"/>
</Grid>

Importantly, the background color is transparent but visible to hit testing. #00000000 would not work as expected because clicking on the TextBox would actually be clicking on the ProgressBar.

You could also retemplate the TextBox to incorporate the ProgressBar more intrinsically into its template. However, this would be of limited use unless you wrote your own control while you're at it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文