Reputation: 1446
I have wpf application with the following xaml as the mainwindow
<Window x:Class="Video_Editor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
</Grid>
</Window>
I also have a class that inherits 'Control' called 'MyControl'. How do I make it possible to put an instance of that MyControl inside the xaml.
Something like this
<Grid>
<MyControl/>
</Grid>
Upvotes: 2
Views: 304
Reputation: 564891
You need to setup the XAML namespace mapping:
<Window x:Class="Video_Editor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:YourNamespaceContainingMyControl"
Title="MainWindow" Height="350" Width="525">
<Grid>
<local:MyControl />
</Grid>
</Window>
Note that, if the control is in a different assembly (DLL), you'll need to use xmlns:local="clr-namespace:YourNamespaceContainingMyControl;assembly=YourLibrary"
.
Upvotes: 1