locked
Load XAML in "Sub Main" (Horst Klein) - 12/13/2006 3:56 AM PST RRS feed

  • Question

  • By: Horst Klein

    I try to load a xaml on this way the XAML-Window is shown.
    But if I close the Window the process will not be terminated!
    
    What's wrong?
    
    <Application x:Class="App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Startup="AppStartUp"
    ShutdownMode="OnMainWindowClose"
    />
    
    Private Sub AppStartup(ByVal sender As Object, ByVal e As StartupEventArgs)
      Try
        ParseCommandLineArgs(e)
        ExecuteCommandLineArgs()
      Catch ex As Exception
        MessageBox.Show(ex.ToString)
      End Try
    End Sub
    
    Private Sub ExecuteCommandLineArgs()
      Dim mainWindow As String = 
    App.CommandLineArgs.Item("/mainwindow").ToString
      Dim xamlStream As FileStream = New FileStream("C:\WPF Test\" + mainWindow 
    + ".xaml", FileMode.Open)
      Dim genericControl As ContentControl = XamlReader.Load(xamlStream)
    
      Me.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose
      Me.MainWindow = DirectCast(genericControl, Window)
      Me.MainWindow.ShowDialog()
      Me.Shutdown()
    
    End Sub
    
    
    Tuesday, February 19, 2008 6:55 PM

Answers

  • By: Lingesh Palaniappan (MS)
    Hi,
    I just tried the same scenario and it seems to work as expected.
    I ran the program, the window popped up for a moment and then shut down
    immediately. The process was gone as well.
    If you are not seeing this could you please share the project.
    Thanks!
    regards,
    Lingesh
    "Horst Klein" <HorstKlein@discussions.microsoft.com> wrote in message
    news:D8375CE8-5705-4DFF-9D26-6109AF297D76@microsoft.com...

    Click to show or hide original message or reply text.


    Tuesday, February 19, 2008 8:13 PM

All replies

  • By: Lingesh Palaniappan (MS)
    Hi,
    I just tried the same scenario and it seems to work as expected.
    I ran the program, the window popped up for a moment and then shut down
    immediately. The process was gone as well.
    If you are not seeing this could you please share the project.
    Thanks!
    regards,
    Lingesh
    "Horst Klein" <HorstKlein@discussions.microsoft.com> wrote in message
    news:D8375CE8-5705-4DFF-9D26-6109AF297D76@microsoft.com...

    Click to show or hide original message or reply text.


    Tuesday, February 19, 2008 8:13 PM
  • By: Horst Klein
    Hi Lingesh

    Thanks a lot for you feedback !

    Meantime I have found the causer.
    I build a new Project doing the same.
    But not really the same:
    In the original Project I used a FormsFacade function from our
    Business-Layer to load the Xaml from the file System.
    On in my testproject I used a filestream to load the Xaml and on this way I
    dont have this problem.
    I have contacted our Business-Layer developer to debug the problem.

    Horst

    Tuesday, February 19, 2008 8:14 PM
  • By: Horst Klein
    The problem was in our Businesslogic. Now it's fixed!
    Based on our sample my Application starts and ends fine ;-)

    Thanks, Lingesh

    Best regards
    Horst

    Tuesday, February 19, 2008 8:14 PM