2012-05-15 67 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实例调用)。

相关问题