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:
Now open our WPF window and add a reference of our current project (or the project which contains our user control), just like using:
xmlns:uc="clr-namespace:WpfApplication1"
Now write the following line of XAML code in the main content of the window:
Run the project and the toolbar control will be load with the above user control.
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>
</StackPanel>
<Label Content="Name"></Label>
<TextBox Width="50"></TextBox>
<Label Content="Age"></Label>
<TextBox Width="40"></TextBox>
</StackPanel>
Now open our WPF window and add a reference of our current project (or the project which contains our user control), just like using:
xmlns:uc="clr-namespace:WpfApplication1"
Now write the following line of XAML code in the main content of the window:
<ToolBar Name="toolbarControl">
<uc:UserControl1></uc:UserControl1>
</ToolBar>
<uc:UserControl1></uc:UserControl1>
</ToolBar>
Run the project and the toolbar control will be load with the above user control.