【发布时间】:2013-09-13 18:59:21
【问题描述】:
我正在使用 WPF MVVM 在 Excel 2007 中创建向导。向导代码基于 this internationalized wizard。
因为 WPF 必须包含在 ElementHost 中,所以我的所有视图都是用户控件,所以没有 App.xaml。相反,我在实例化主机 WinForm 并动态绑定我的应用程序资源时创建我的 WPF 应用程序,如 here 所述。
Private _wpfApplication As Windows.Application
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' WPF application instance
_wpfApplication = Application.Current()
If Application.Current Is Nothing Then
_wpfApplication = New Application()
End If
' Merge in your application resources.
_wpfApplication.Resources.MergedDictionaries.Add(TryCast(Application.LoadComponent(New Uri("Pitchbook.Excel.ChartWizard;Component/Themes/Generic.xaml", UriKind.Relative)), ResourceDictionary))
End Sub
Private Sub ChartWizard_Load(sender As Object, e As System.EventArgs) Handles Me.Load
' Create the WPF UserControl.
Dim uc As New MainWindow()
' Assign the WPF UserControl to the ElementHost control's child property.
ehMaster.Child = uc
End Sub
这适用于我目前创建的一个模块。我有许多模块要创建,而不是每个模块都有一个 WinForm 容器,我真的很想通过使用 Prism 创建一个复合应用程序来将应用程序提升到一个新的水平。我想以某种方式拥有一个与 App.xaml 起类似作用的通用 WinForm。当用户单击功能区上的按钮时,我可以启动此通用主机 WinForm 将 Shell.xaml 绑定到 ElementHost 并使用引导程序根据将功能区按钮映射到一组模块的某些参数或配置加载相关模块应该加载到通用主机容器中。
我正在为这样做的逻辑而苦苦挣扎,我想就这种方法的可行性以及是否可能是最好的方法获得一些意见。基本上我需要将红色的两层添加到现有的复合应用程序架构中。
http://www.patternjuggler.org/downloads/officecompositeapp.jpg
【问题讨论】: