J'ai créé une logique pour l'application singleInstance et je dois utiliser mon propre point d'entrée (pas App.xaml) pour Application. J'ai quelques styles dans App.xaml qui ne fonctionne pas maintenant. Comment puis-je utiliser ce ResourceDictionaries de mon App.xaml pour l'ensemble du projet dans ma situation?Comment utiliser ResourseDictionaries de App.Xaml avec son propre point d'entrée
Ma classe pour gérer l'application de démarrage
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();
}
}
et mon propre point d'entrée:
public class EntryPoint
{
[STAThread]
public static void Main(string[] args)
{
SingleInstanceManager manager = new SingleInstanceManager();
manager.Run(args);
}
}
Et mon code app.xaml derrière:
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();
}
}
Et mon App.xaml a un code qui décrit ResourceDictionaries qui ne fonctionne pas. Pourquoi?
Si vous souhaitez que l'EDI utilise les styles définis ici dans l'éditeur, vous pouvez ajouter une référence au dictionnaire de ressources principal dans App.xaml. Cependant, l'application fera toujours l'affectation en utilisant le code-behind – sridawg