WPF: How to start from a window in a different assembly

前端 未结 3 979
梦如初夏
梦如初夏 2020-12-29 05:17

I googled this and still can\'t get it working

I have a WPF app and want to start from Main.xaml which is located in a different assembly. Both assemblies are in the

3条回答
  •  甜味超标
    2020-12-29 05:55

    This article gives a clean XAML-only solution.

    StartupUri="pack://application:,,,/assembly_name;component/path/file_name.xaml"
    

    Where:

    • assembly_name is the name of the referenced assembly, sans extension
    • path is the subfolder in which the component resides; if the component is at the project root, this element is omitted
    • file_name is the file name of the component

    Examples:

    pack://application:,,,/UI;component/CalculatorView.xaml
    assembly - UI.dll
    path - none (file at project root)
    file_name - CalculatorView
    
    pack://application:,,,/MyApp.UI;component/Views/CalculatorView.xaml
    assembly - MyApp.UI.dll
    path - Views
    file_name - CalculatorView
    
    pack://application:,,,/UI;component/Views/External/CalculatorView.xaml assembly - UI.dll
    path - Views/External
    file_name - CalculatorView 
    

提交回复
热议问题