By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,156 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,156 IT Pros & Developers. It's quick & easy.

Path to xaml resource file

P: n/a
I have a user control located in the following path:

projectFolder/PropertyControls/myControl.xaml

and in myControl.xaml I have a reference to a resource dictionary like this:

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="Resources/ControlResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

However this doesn't compile because ControlResourceDictionary.xaml is
located under the main project folder like this:

projectFolder/Resources/ControlResourceDictionary.xaml

What's the correct way to show this path in myControl.xaml?

Thanks.

--
mo*******@newsgroup.nospam
Aug 25 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hello,

Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou. It's
my pleasure to work with you on this thread.
If I understand you correctly, you have a UserControl which resides in
"PropertyControls" subfolder under the current project, and inside this
UserControl, you need to merge a resource dictionary file which resides in
another subfolder say "Resources". If this is the case, there are two
options you could try:
First option:
If the current project is a custom control library, you could use the
following the pack URI syntax to refer to the resource dictionary file:
Assemblyname;component/Resources/ControlResourceDictionary.xaml

"Assemblyname" is the name of the assembly which is built from the current
project. For instance, if your project name is "MyCustomControlLib", then
you could name the assembly as "MyCustomControlLib", so the pack URI will
be:
MyCustomControlLib;component/Resources/ControlResourceDictionary.xaml

Second option:
If the current project is a WPF executable project, you could use the
following pack URI instead:
pack://application:,,,/Resources/ControlResourceDictionary.xaml

For more information on pack URI scheme, you could refer to the following
link:
http://msdn.microsoft.com/en-us/library/aa970069.aspx

If you continue having any further questions on this issue, free feel to
ask here, we are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou (v-*****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 25 '08 #2

P: n/a
moondaddy wrote:
I have a user control located in the following path:

projectFolder/PropertyControls/myControl.xaml

and in myControl.xaml I have a reference to a resource dictionary like this:

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="Resources/ControlResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

However this doesn't compile because ControlResourceDictionary.xaml is
located under the main project folder like this:

projectFolder/Resources/ControlResourceDictionary.xaml

What's the correct way to show this path in myControl.xaml?

<ResourceDictionary Source="../Resources/ControlResourceDictionary.xaml"/>

Alun Harford
Aug 25 '08 #3

P: n/a
Thanks Alun! This worked.
"Alun Harford" <de*****@alunharford.co.ukwrote in message
news:ut**************@TK2MSFTNGP06.phx.gbl...
moondaddy wrote:
>I have a user control located in the following path:

projectFolder/PropertyControls/myControl.xaml

and in myControl.xaml I have a reference to a resource dictionary like
this:

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="Resources/ControlResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>

However this doesn't compile because ControlResourceDictionary.xaml is
located under the main project folder like this:

projectFolder/Resources/ControlResourceDictionary.xaml

What's the correct way to show this path in myControl.xaml?


<ResourceDictionary Source="../Resources/ControlResourceDictionary.xaml"/>

Alun Harford

Aug 25 '08 #4

P: n/a
Thanks Marco,

To make your suggestion work, I had to use the following syntax:

<ResourceDictionary
Source="pack://application:,,,/UIControls;component/Resources/ControlResourceDictionary.xaml"/>

where UIControls is the assembly name. Alun's suggestion also worked with
the following syntax:

<ResourceDictionary Source="../Resources/ControlResourceDictionary.xaml"/>

"Marco Zhou [MSFT]" <v-*****@online.microsoft.comwrote in message
news:kw**************@TK2MSFTNGHUB02.phx.gbl...
Hello,

Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou.
It's
my pleasure to work with you on this thread.
If I understand you correctly, you have a UserControl which resides in
"PropertyControls" subfolder under the current project, and inside this
UserControl, you need to merge a resource dictionary file which resides in
another subfolder say "Resources". If this is the case, there are two
options you could try:
First option:
If the current project is a custom control library, you could use the
following the pack URI syntax to refer to the resource dictionary file:
Assemblyname;component/Resources/ControlResourceDictionary.xaml

"Assemblyname" is the name of the assembly which is built from the current
project. For instance, if your project name is "MyCustomControlLib", then
you could name the assembly as "MyCustomControlLib", so the pack URI will
be:
MyCustomControlLib;component/Resources/ControlResourceDictionary.xaml

Second option:
If the current project is a WPF executable project, you could use the
following pack URI instead:
pack://application:,,,/Resources/ControlResourceDictionary.xaml

For more information on pack URI scheme, you could refer to the following
link:
http://msdn.microsoft.com/en-us/library/aa970069.aspx

If you continue having any further questions on this issue, free feel to
ask here, we are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou (v-*****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.

Aug 25 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.