2013-04-24 88 views

回答

0

Dispatcher.BeginInvoke()方法应该通过不带参数的委托(参见http://msdn.microsoft.com/en-us/library/0b1bf3y3.aspx)。你可以将你的参数传递给你的方法之外。修订

public void SetContentObject(Type contentType) 
    { 
     Type input; 
     Dispatcher.BeginInvoke(new Action(delegate 
     { 
       object obj = Activator.CreateInstance(input); 
       this.Content = obj;    

     }), new object[] 
     { 
      contentType 
     }); 
    } 
+0

此错误仍然存​​在。有任何想法吗? – Superjet100 2013-04-24 07:05:16

+0

对不起,如果忘了把代理放入Action实例 – Alex 2013-04-24 07:21:15

+0

谢谢!现在编译! – Superjet100 2013-04-24 08:05:08

0

您可能会调用而BeginInvoke混淆:

public void Invoke(Action callback, DispatcherPriority priority) 

//no priority is allowed below. 
public DispatcherOperation BeginInvoke(Action a) 
相关问题