Reputation: 3515
I have custom user control. Namespace where this control belong is imported and is added to the window.resources element like
<Window
...
xmlns:Views="clr-namespace:MyPrj.WPF.Views">
<Window.Resources>
<Views:AddEditData x:Key="AddEditView" />
...
Question is: how to render this control inside grid or any other panel using xaml?
Upvotes: 0
Views: 261
Reputation: 81243
Instead of placing it under resource section. Put that inside some panel and it will be rendered.
<Window xmlns:Views="clr-namespace:MyPrj.WPF.Views">
<DockPanel>
<Views:AddEditData x:Name="AddEditView" />
</DockPanel>
</Window>
Or in case you place it under Resource section, you need ContentControl
to get it render like this:
<Window xmlns:Views="clr-namespace:MyPrj.WPF.Views">
<Window.Resources>
<Views:AddEditData x:Key="AddEditView" />
</Window.Resources>
<DockPanel>
<ContentControl Content="{StaticResource AddEditView}"/>
</DockPanel>
</Window>
Upvotes: 1