后PivotItem pivotItem = new PivotItem();
我得到Additional information: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
。它应该是什么?我很困惑它。C#:数据透视项创建出错
代码:
foreach (Source source in sources)
{
PivotItem pivotItem = new PivotItem(); /* At this point it falls. */
pivotItem.Header = source.Name;
pivotItem.Margin = new Thickness(0, -10, 0, 0);
ListView listView = new ListView();
listView.ItemsSource = source.Articles;
listView.ItemTemplate = (DataTemplate)Resources["MainItemTemplate"];
listView.ItemClick += OpenArticle_ItemClick;
listView.SelectionMode = ListViewSelectionMode.None;
listView.IsItemClickEnabled = true;
pivotItem.Content = listView;
pvtMain.Items.Add(pivotItem);
}
我不知道,没有任何额外的上下文(“错误代码或任何细节”),我们可以帮助你。 –
@EugenePodskal请仔细阅读我编辑的帖子,提供错误的详细信息。 –
什么是'PivotItem'?你在什么情况下调用这个代码?不要只发布异常错误消息,发布[MCVE]。 –