-2

I would like to know if this names (StartupUri="MainWindow.xaml" and MainWindow.xaml) should coincide. For example, if I'm going to rename MainWindow.xaml to e.g. MsgBox.xaml.

Please look at pic and code sample.

Solution explorer tree view

App.xaml of project CustomMessageBox

<Application x:Class="CustomMessageBox.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:CustomMessageBox"
         StartupUri="MainWindow.xaml"> <!-- this name -->
<Application.Resources>

</Application.Resources>

Please any comments and thanks in advance.

5
  • Yes, they must coincide. StartupUri defines the resource (window) that will be load at application's start up event Commented Oct 17, 2018 at 11:44
  • Another way would be to handle what you want to show by overriding Application's OnStartUp method and calling something like new MsgBox().Show() if you go this way then you should get rid of StartupUri markup Commented Oct 17, 2018 at 11:46
  • More info here Commented Oct 17, 2018 at 11:47
  • I've got that.Thank you. Commented Oct 17, 2018 at 11:55
  • Thank you guys. This is my yesterdays buried question on the similar issue. Could someone make some comments? stackoverflow.com/questions/52838171/… Commented Oct 17, 2018 at 11:59

1 Answer 1

1

That is the name of the window that will be opened when the app starts. If you rename the window without changing the StartupURI you will get a System.IO.IOException, Cannot locate resource 'mainwindow.xaml'.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you guys. This is my yesterdays buried question on the similar issue. Could someone make some comments? stackoverflow.com/questions/52838171/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.