如何通过自己的入口点使用 App.Xaml 的 ResourseDictionaries
我为 singleInstance 应用程序创建了一些逻辑,并且必须使用我自己的应用程序入口点(不是 App.xaml)。我在 App.xaml 中有一些样式现在不起作用。在我的情况下,如何在整个项目中使用 App.xaml 中的这个 ResourceDictionaries?
我的管理应用程序启动的类
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 的代码,但它不起作用。为什么?
I created some logic for singleInstance application and I must to use my own entry point (not App.xaml) for Application. I have some styles in App.xaml which now is not working. How can I use this ResourceDictionaries from my App.xaml for entire project in my situation?
My class for manage Application Startup
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();
}
}
and my own Entry Point:
public class EntryPoint
{
[STAThread]
public static void Main(string[] args)
{
SingleInstanceManager manager = new SingleInstanceManager();
manager.Run(args);
}
}
And my App.Xaml code behind:
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();
}
}
And my App.xaml has some code which decribe ResourceDictionaries which doesnt work. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了这个问题的解决方案。我创建新的资源字典并将所有其他资源粘贴到这个新字典中:
然后只是编辑了一点我的 App.cs
我希望这个解决方案可以帮助别人)))
I found solution for this problem. I create new Resource Dictionary and paste all my other Resourse in this new dictionary:
and then just edited a little bit my App.cs
I hope this solution help somebody )))