gpt4 book ai didi

wpf-controls - WPF - 向动态添加的 Tabitem 添加动态控件?

转载 作者:行者123 更新时间:2023-12-04 03:11:10 28 4
gpt4 key购买 nike

我在运行时(在 C# 中)将 Tabitems 动态添加到 Tab Control 并且工作正常,但是我如何才能将控件动态添加到新的 Tabitems? Tabitems 需要是动态的,因为它们取决于从数据库中读取的数据行数。每个 Tabitem 的布局都是相同的。谢谢

最佳答案

使用 Content新 TabItem 的属性,您可以在其中设置任何内容,例如字符串或其他 WPF 控件:

private void AddChildControl(TabItem tabItem)
{
StackPanel newChild = new StackPanel();
tabItem.Content = newChild;
}

关于wpf-controls - WPF - 向动态添加的 Tabitem 添加动态控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4535868/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com