I have a user control that I've created, however when I go to add it to the XAML in the window, Intellisense doesn't pick it up, and I can't figure out how to add it to the window.
The XamlFileBrowser Control Create a XAML application using Visual Studio 2008 and add a new item by right clicking on the project, select Add >> New Item from the menu and select User Control from the available templates.
<Grid. ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
User controls, in WPF represented by the UserControl class, is the concept of grouping markup and code into a reusable container, so that the same interface, with the same functionality, can be used in several different places and even across several applications.
Add a WPF control to a Windows FormOpen Form1 in the Windows Forms Designer. In the Toolbox, find the tab labeled WPFUserControlLibrary WPF User Controls. Drag an instance of UserControl1 onto the form. An ElementHost control is created automatically on the form to host the WPF control.
You need to add a reference inside the window tag. Something like:
xmlns:controls="clr-namespace:YourCustomNamespace.Controls;assembly=YourAssemblyName"
(When you add xmlns:controls=" intellisense should kick in to make this bit easier)
Then you can add the control with:
<controls:CustomControlClassName ..... />
You probably need to add the namespace:
<Window x:Class="UserControlTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:UserControlTest" Title="User Control Test" Height="300" Width="300"> <local:UserControl1 /> </Window>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With