views:

41

answers:

1

I have a custom Silverlight user control (which resides in a separate DLL we'll call usercontrol.dll) that builds a simple 3D page turning book. I have a project referencing this DLL and the project also has a folder, Pages, that contains all of the pages. The pages are labelled "page_1.xaml, page_2.xaml, ..., page_n.xaml." The number of pages in a book is variable.

I want to use the custom control in my project as follows:

<customControls:BookControl />

Short and sweet. To make things work, I want the BookControl to "reach out" from within its assembly to the parent project that is calling it and read through the "Pages" folder to automatically load each page into the book.

I'm trying to avoid passing in parameters. If the DLL can read through the projects folder and create a list of pages then I will have solved all of my problems.

My problem right now is that I don't know how to call out to the parent project and read through the Pages folder.

How can I access the folder of a Silverlight project from a referenced DLL?

+2  A: 

The simplest way to allow the usercontrol to access to things from the hosting application is by putting a property on the usercontrol - this way the application "hands off" the services/info required by the usercontrol, rather than the control assuming knowledge of the application.

where pages is a list of pages

<customControls:BookControl Pages="{Binding pages}"/> 

or the directory name instead, or whatever info you really need.

<customControls:BookControl PageDirectory="{Binding pageDirectory}"/> 
Philip Rieck
I'm hoping to not pass in a list of pages as I 'm trying to make usage of the control super simple. I would prefer to have the assembly build the list of pages internally without the parent project getting involved.
Marvin Aldrige