StructureMapを使用したIOCのWPFの例をAutoFacを使用してSilverlightに変換しようとしています
これは非常に難しいことが証明されています
静的なBootStrapperクラスを定義しました
public class BootStrapper
{
public static IContainer BaseContainer { get; private set; }
public static FlexContractStructureViewModel FlexContractStructureViewModel()
{
return BaseContainer.Resolve<FlexContractStructureViewModel>();
}
public static void Build()
{
if (BaseContainer == null)
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyTypes();
BaseContainer = builder.Build();
}
}
static BootStrapper()
{
}
}
これは、App.xaml.csのApplication_Startupで初期化されます
private void Application_Startup(object sender, StartupEventArgs e)
{
BootStrapper.Build();
this.RootVisual = new MainPage();
}
BootStrapperを使用するようにビューの1つのDataContextを設定しました
DataContext="{Binding Path=FlexContractStructureViewModel,
Source={StaticResource classes:BootStrapper}}"
しかし、「名前/キークラスのリソースが見つかりません:BootStrapper」というエラーが発生します
追加するApp.xamlに変更を加えるために州を使用している本
しかし、ObjectDataProviderが認識されないため、それはできません。
私は運がなくて以下の同等のものを試しました
<bs:BootStrapper xmlns:bs="clr-namespace:SLDashboard2.Classes" x:Key="BootStrapper"/>
これはBootStrapperを静的にすることに関連していると思いますか?しかし、私は常に新しいコンテナを作成したくありません
誰か助けてもらえますか?
ポール