How to Load UserControl in ToolBar Control: WPF

In earlier post I have placed some images and labels in toolbar control using some lines of XAML code. Now if we want to load a user control, written in another file, we have so follow some steps like the below.

Just add a user control through “Add New Item” from the file menu or from the right click on the project. Rename it if you want and write the following XAML code to add two labels and two textbox in this user control:
<StackPanel Orientation="Horizontal">
<Label Content="Name"></Label>
<TextBox Width="50"></TextBox>
<Label Content="Age"></Label>
<TextBox Width="40"></TextBox>

Now open our WPF window and add a reference of our current project (or the project which contains our user control), just like using:


Now write the following line of XAML code in the main content of the window:
<ToolBar Name="toolbarControl">

Run the project and the toolbar control will be load with the above user control.

How to load user control in toolbar control: WPF XAML


Post a Comment