在$('input').each(function() {
$(this).toggleClass('error', this.value == "");
});
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))
。它应该是什么?我很困惑。
代码:
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);
}
答案 0 :(得分:1)
基于异常,您似乎尝试在UI线程以外的线程中创建新的 <asp:GridView ShowHeader="false" AutoGenerateColumns="false" ID="GridView1" runat="server" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="QuestionID" Text='<%# Eval("QuestionID")%>' />
<asp:Label runat="server" ID="Question" Text='<%# Eval("Question")%>' /><br />
<asp:RadioButton GroupName="a" Text='<%# Eval("answer1")%>' runat="server" ID="answer1" /><br />
<asp:RadioButton GroupName="a" Text='<%# Eval("answer2")%>' runat="server" ID="answer2" /><br />
<asp:RadioButton GroupName="a" Text='<%# Eval("answer3")%>' runat="server" ID="answer3" /><br />
<asp:RadioButton GroupName="a" Text='<%# Eval("answer4")%>' runat="server" ID="answer4" /><hr />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
<asp:Label ID="lblOutput" runat="server" Text="" />
。您只能与UI线程中的UI元素进行交互。
您可能正在从未从UI事件触发的事件处理程序中调用此代码。您应该能够使用Dispatcher
切换回UI线程来解决问题:
PivotItem