简体   繁体   English

在WPF中在线程中动态创建控件

[英]Dynamically create controls in thread in WPF

In my WPF form i have button Control when i click that button Dynamically tabcontroll is added in the form inside that tab control one page is there. 在我的WPF表单中,当我单击该按钮时,我具有按钮“控件”。动态地将tabcontroll添加到该标签控件内部的表单中,其中一页。 On that page many data are there .so the tabcontrol take time to load in the form. 在该页面上,有许多数据。因此,tabcontrol需要花费一些时间来加载表格。

I want to show the tab control first then i want to add the page in the tab. 我想先显示选项卡控件,然后再在选项卡中添加页面。 Is it Possible with the help of background worker or any other thread. 是否有可能在后台工作者或任何其他线程的帮助下进行的。

The problem is that UI elements have to be created on the UI thread. 问题在于必须在UI线程上创建UI元素。 So you cannot create those elements in a different thread, such as in a BackgroundWorker. 因此,您不能在其他线程(例如BackgroundWorker)中创建这些元素。

If getting the data is the slow part, you could use PriorityBindings . 如果获取数据比较缓慢,则可以使用PriorityBindings

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM