Splitting WPF interface across multiple Xaml files

You can split a large user interface by defining UserControls.

Right-click on the solution tree, choose Add->New Item… then User Control. You can design this in the normal way.

You can then reference your usercontrol in XAML using a namespace declaration. Let’s say you want to include your UserControl in a Window. In the following example I’ve added a UserControl named “Foo” to the namespace “YourCompany.Controls”:

<Window x:Class="YourCompany.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:YourCompany.Controls">

  <Controls:Foo ... />

For your specific example, you would make use of your usercontrol in a combobox by defining a DataTemplate that displayed the data within your usercontrol.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)