How to set the startup object in WPF?
-
Hello, I would like to set the object as a startup object in WPF. Normally, we used to use "this.StartupUri" for that. but I have to use the Uri of XAML file here. I don't like that. I want to set like this.Startup = new MyView(); in App. Any idea? Thanks in advance. Edit: My WPF project should be XBAP-compatible. So, I can't use "Show()" or "Run()" method....
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Hello, I would like to set the object as a startup object in WPF. Normally, we used to use "this.StartupUri" for that. but I have to use the Uri of XAML file here. I don't like that. I want to set like this.Startup = new MyView(); in App. Any idea? Thanks in advance. Edit: My WPF project should be XBAP-compatible. So, I can't use "Show()" or "Run()" method....
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Michael Sync wrote:
this.Startup = new MyView(); in App
Would the Application.MainWindow property work for you?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
-
Michael Sync wrote:
this.Startup = new MyView(); in App
Would the Application.MainWindow property work for you?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns
Wes Aday wrote:
Would the Application.MainWindow property work for you?
I just tried but not working. It doesn't show anything on the screen unless we call "Show". But I can't use it "Window" class in Xbap.. I'm not sure why we don't have this.Startup or this.StartUpObject even we have this.StartupUri.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
-
Hello, I would like to set the object as a startup object in WPF. Normally, we used to use "this.StartupUri" for that. but I have to use the Uri of XAML file here. I don't like that. I want to set like this.Startup = new MyView(); in App. Any idea? Thanks in advance. Edit: My WPF project should be XBAP-compatible. So, I can't use "Show()" or "Run()" method....
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)
Hi Michael, You would need to modify app.g.i.cs file. Then find StartupURI property of application and modify as: this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative); Hope this helps.
Vinay ComponentOne LLC. www.componentone.com
-
Hi Michael, You would need to modify app.g.i.cs file. Then find StartupURI property of application and modify as: this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative); Hope this helps.
Vinay ComponentOne LLC. www.componentone.com
Vinay Srivastava wrote:
this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);
Actually, we would like to use with Unity framework.. I have successfully ported Unity framework for Silverlight.. I want to use the code below at that startup..
this.Startup = container.Resolve<shell>();
How can I do that? In Silverlight, we can do like that..
private void Application_Startup(object sender, StartupEventArgs e) {
IUnityContainer container = new UnityContainer()
.RegisterType<ILogger, TraceLogger>()
.RegisterType<IStoplightTimer, RealTimeTimer>();//this.RootVisual = new StoplightView(); this.RootVisual = (UIElement)container.Resolve<StoplightView>(); }
Ref: http://michaelsync.net/2008/07/11/unity-application-block-unity-for-silverlight-and-stoplight-quickstart[^]
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)