Reading the folder structure of a parent Silverlight project from a child assembly

I have a custom Silverlight user control (which is in a separate DLL, we will call usercontrol.dll), which creates a simple three-dimensional book. I have a project referencing this DLL, and the project also has a Pages folder containing all the pages. Pages are marked as "page_1.xaml, page_2.xaml, ..., page_n.xaml". The number of pages in a book is a variable.

I want to use a user control in my project as follows:

<customControls:BookControl /> 

Short and sweet. For everything to work, I want BookControl to "go out" from within its assembly to the parent project, which calls it, and read the Pages folder to automatically load each page into the book.

I am trying to avoid passing parameters. If the DLL can read the project folder and create a list of pages, then I will solve all my problems.

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

How can I access the Silverlight project folder from the specified DLL?

+4
source share
1 answer

The easiest way to allow usercontrol to access things from a hosting application is to add a property to usercontrol - this way the application β€œtears off” the services / information required by user control, rather than the control assuming knowledge of the application.

where pages is a list of pages

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

or the name of the directory, or any information that you really need.

 <customControls:BookControl PageDirectory="{Binding pageDirectory}"/> 
+2
source

All Articles