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?
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.