Splitting WPF interface across multiple Xaml files

后端 未结 4 1301
南旧
南旧 2020-12-25 09:51

I am trying to create a user interface using XAML. However, the file is quickly becoming very large and difficult to work with. What is the best way for splitting it across

4条回答
  •  庸人自扰
    2020-12-25 10:17

    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":

    
    
      
    

    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.

提交回复
热议问题