Page reuse in Silverlight
Suppose many Silverlight applications need a function encapsulated by a page (e.g. Feedback.xaml), this page should be created only once, and used everywhere according to DRY (Don't Repeat Yourself) principle. The reuse of a page is very straightforward as following:
- Create a User Control page in a Silverlight class library project which usually already exists to contain reusable functions. This may not sound intuitive.
- Add the class library project to the references of the project where this page will be used.
- Add the name space of the class library to the page where the reusable page (or control) will be used (e.g. add xmlns:MyClassLibrary="clr-namespace:MyClassLibrary;assembly=MyClassLibrary" ).
- Use the reusable control just like using other controls (e.g. <MyClassLibrary:Feedback/>