2
我为singleInstance应用程序创建了一些逻辑,我必须使用我自己的入口点(而不是App.xaml)作为Application。我在App.xaml中有一些样式现在不起作用。如何在我的情况下使用我的App.xaml中的这个ResourceDictionaries来完成整个项目?如何使用App.Xaml的ResourseDictionaries和自己的入口点
我的类管理应用程序启动
public class SingleInstanceManager : WindowsFormsApplicationBase
{
App app;
public SingleInstanceManager()
{
this.IsSingleInstance = true;
}
protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
{
try
{
// First time app is launched
app = new App();
App.Current.Properties["rcID"] = e.CommandLine;
//IntroLibrary.OpenDocumentFromNotify();
app.Run();
return false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
}
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
{
// Subsequent launches
base.OnStartupNextInstance(eventArgs);
Intro win = (Intro)app.MainWindow;
if (eventArgs != null)
{
App.Current.Properties["rcID"] = eventArgs.CommandLine[0];
}
IntroLibrary.OpenDocumentFromNotify();
app.Activate();
}
}
和我自己的入口点:
public class EntryPoint
{
[STAThread]
public static void Main(string[] args)
{
SingleInstanceManager manager = new SingleInstanceManager();
manager.Run(args);
}
}
背后我的App.xaml代码:
public partial class App : Application
{
protected override void OnStartup(System.Windows.StartupEventArgs e)
{
base.OnStartup(e);
// Create and show the application's main window
Intro window = new Intro();
window.Show();
}
public void Activate()
{
// Reactivate application's main window
this.MainWindow.Activate();
}
}
而我的App.xaml有一些代码描述了不起作用的ResourceDictionaries。为什么?
如果您希望IDE在编辑器中使用此处定义的样式,则可以在App.xaml中添加对主资源字典的引用。但是,应用程序仍然会使用代码隐藏进行分配 – sridawg 2015-11-17 19:48:09