Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. How to set the startup object in WPF?

How to set the startup object in WPF?

Scheduled Pinned Locked Moved WPF
csharpwpftutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Sync
    wrote on last edited by
    #1

    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)

    L J 2 Replies Last reply
    0
    • M Michael Sync

      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)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • L Lost User

        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

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #3

        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)

        1 Reply Last reply
        0
        • M Michael Sync

          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)

          J Offline
          J Offline
          John Ad
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • J John Ad

            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

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #5

            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)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups