|
Custom classes that are used in XAML can be defined in two distinct ways within
the code-behind or other code that produces the primary Windows Presentation
Foundation (WPF) application or as a class in a separate assembly such as an
executable or DLL used as a class library. Each of these approaches have
advantages and disadvantages.
The advantage of creating a class library is that any such custom class can be
shared across many different possible applications. A separate library also
makes versioning issues of applications easier to control and simplifies
creating a class that you intend to use as a root element on an XAML page.
he advantage of defining the custom classes in the application is that this
technique is relatively lightweight and minimizes the deployment and testing
issues encountered when you introduce separate assemblies beyond the main
executable. However, one notable disadvantage is that you cannot use classes
defined in the same assembly as the root element of an XAML page.
Whether defined in the same or different assembly, custom classes need to be
mapped between the CLR namespace and XML namespace in order to be used in XAML
as elements.
|