Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Window implemented in subfolder not avaiable for StartUri

Tags:

c#

.net

wpf

xaml

A novice question about WPF.

I'm just at the beginning of a draft project. I have define a really simple window testWindow1.xaml, located in the solution subfolder Tests.

In App.xaml I cannot do:

StartupUri="testWindow1.xaml"

(unless I move the testWindow1.xaml back to the root of the project)

I have also tried defining my namespace into the App.xaml tag, but without success, this wont work either.

<Application x:Class="MyProject.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:myprojectNS="clr-namespace:MyProject"
             StartupUri="myprojectNS.tests.testWindow1.xaml">

At run time, the exception message complains about not finding the ressource *testWindow1.xaml

like image 607
Stephane Rolland Avatar asked Apr 17 '11 15:04

Stephane Rolland


1 Answers

Try this -

<Application x:Class="MyProject.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:myprojectNS="clr-namespace:MyProject"
             StartupUri="tests\testWindow1.xaml">

You just need to specify the hierarchy.

like image 87
Rohit Vats Avatar answered Nov 13 '22 13:11

Rohit Vats