Reputation: 219
I want to make program name Cyan Pembuat Soal(Cyan Question Maker) I add the startup event to this Code:
using System;
using System.Windows;
namespace Cyan_Pembuat_Soal {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
private void Application_Startup(object sender, StartupEventArgs e){
if (FindPlace(e.Args) != null) {
Cyan_Pembuat_Soal.MainWindow a = new Cyan_Pembuat_Soal.MainWindow();
a.Activate();
} else {
Cyan_Pembuat_Soal.MainWindow a = new Cyan_Pembuat_Soal.MainWindow();
a.Activate();
a.Closed += delegate(object senders, EventArgs es) {this.Shutdown();};
}
}
private static string FindPlace(string[] a) {
if (a.Length == 0) {
return null;
}
int b = 0;
System.Uri c;
for (b = 0; b < a.Length; b++) {
if(Uri.TryCreate(a[b], UriKind.RelativeOrAbsolute, out c)){
break;
}
}
c = null;
return a[b];
}
}
}
But that code did not work properly. What's wrong in this program?
Upvotes: 1
Views: 2448
Reputation: 10376
Use a.Show() instead of a.Activate(); And make sure that your handler is registered in App.Xaml:
<Application
...
Startup="Application_Startup">
Upvotes: 0
Reputation: 26352
I would try to add a.ShowDialog();
or a.Show();
in addition to a.Activate();
.
Not sure why you are using Activate()
, but make sure that it does what you want it do to.
http://msdn.microsoft.com/en-us/library/system.windows.window.activate.aspx
Upvotes: 1