Add a dialog box on application start up in c# / Xaml -


an application need fetch email id , password before starting application. need information processing, application build using xaml/c# ? how can achieve using custom dialog box ?

thank

by default, type "app" autogenerated in new wpf applications (derived application) set startup object (see application properties). may ...

a) replace object own type instantiating app , calling app.run() after credentials have been provided. sure declare entry method [stathread].

  [stathread]         public static int main()   {      myoperations();      var app = new app();      app.run();   } 

b) override onstartup in app.xaml.cs:

  protected override void onstartup(startupeventargs e)   {      base.onstartup(e);      myoperations();   } 

edit: may have missed point. if aim show wpf window before showing main one, can use option b), may have modify application.current.shutdownmode before showing login mask, or else program terminate after closing it.

so, content of existing file app.xaml.cs (its hidden in solution explorer, have expand app.xaml see it).

using system.windows;  namespace wpfapplication1 {    /// <summary>    /// interaction logic app.xaml    /// </summary>    public partial class app : application    {       protected override void onstartup(startupeventargs e)       {          base.onstartup(e);          shutdownmode = shutdownmode.onexplicitshutdown;          var loginwindow = new login();          loginwindow.showdialog();          if (!loginwindow.loggedin)          {             shutdown();             return;          }          shutdownmode = shutdownmode.onlastwindowclose;       }    } } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -