2012-05-15 89 views
0

我想用下面的代碼顯示PluginManagerView的實例。不包含「顯示」的定義,也沒有擴展方法「顯示」錯誤

此XAML文件位於相同的命名空間,同一項目中。但我在mainwindow.Show();

Error 1 'PluginManager.PluginManagerView' does not contain a definition for 'Show' and no extension method 'Show' accepting a first argument of type 'PluginManager.PluginManagerView' could be found (are you missing a using directive or an assembly reference?) Blah procedyre .cs 30 24 PluginManager 

誰能告訴我是什麼問題行的錯誤?爲什麼它不會拋出MainWindow之前的使用錯誤?

using System; 
using System.Collections.Generic; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Windows; 
using System.ComponentModel.Composition.Hosting; 

namespace PluginManager 
{ 
    public class PublicProcedures : Application 
    { 
     public static void ShowPlugins() 
     { 
      var mainwindow = new PluginManagerView(); 

      //An aggregate catalog that combines multiple catalogs 

      var catalog = new AggregateCatalog(); 
      //Adds all the parts found in the same assembly as the Program class 
      //catalog.Catalogs.Add(new AssemblyCatalog(this.GetType().Assembly)); 
      catalog.Catalogs.Add(new DirectoryCatalog("./Plugins/")); 

      var container = new CompositionContainer(catalog); 

      var modules = container.GetExportedValues<IPlugin>(); 


      mainwindow.DataContext = modules; 
      mainwindow.Show(); 
     } 

    } 


} 

回答

1

爲了調用Window.Show(我猜是你想要做什麼),PluginManagerView將不得不從Window類派生,它的XAML會以某種方式是這樣的:

<Window x:Class="PluginManager.PluginManagerView" ...> 
    ... 
</Window> 
0

據抱怨,無論PluginManagerView是,它沒有一個Show方法(你想在所謂的「主窗口」的PluginManagerView實例調用)。

相關問題