Combining controls
When we need to arrange a number of existing controls in a particular way, we typically use a UserControl
object. This is why we normally use this type of control to build our Views. However, when we need to build a reusable control, such as an address control, we tend to separate these from our Views, by declaring them in a Controls
folder and namespace within our Views project.
When declaring these reusable controls, it is customary to define Dependency Properties in the code behind and as long as there is no business-related functionality in the control, it is also ok to use the code behind to handle events. If the control is business-related, then we can use a View Model, as we do with normal Views. Let's take a look at an example of an address control.
<UserControl x:Class= "CompanyName.ApplicationName.Views.Controls.AddressControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx...