WPF - 动态为 tabitem 创建内容

发布于 2024-07-26 15:35:58 字数 268 浏览 8 评论 0原文

我想根据先前选项卡项上采取的内容/操作动态设置选项卡项的内容。

我通过以下命令在选项卡中前进:

tabControl1.SelectedIndex++;

但是,在此之后 Loaded 事件不会像我想象的那样被触发。 然而,tabControl1_SelectionChanged() 正在被调用。 我应该从 SelectionChanged() 手动调用 tabitem 的 Load() 事件,还是有更好的方法来执行此操作?

I'd like to set the content of a tabitem dynamically, based on the content/actions taken on previous tabitems.

I'm advancing through the tabs via a command like:

tabControl1.SelectedIndex++;

However, the Loaded event doesn't get fired after this like I thought it would. tabControl1_SelectionChanged() is getting called, however. Should I manually call the tabitem's Load() event from SelectionChanged(), or is there a better way of doing this?

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

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

发布评论

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

评论(1

情仇皆在手 2024-08-02 15:35:58

对于每个 TabItem,Load 只会被调用一次。 但您可以从 SelectionChanged 获取所需的 TabItem 实例并设置其内容

Load will get called only once for every TabItem. but you can get the required TabItem instance from the SelectionChanged and set its content

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