WPF - 动态为 tabitem 创建内容
我想根据先前选项卡项上采取的内容/操作动态设置选项卡项的内容。
我通过以下命令在选项卡中前进:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于每个 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