In the code behind (ChildControl.xaml.cs), you simply extend the class as you would do in WinForms.
Then in XAML:
<local:BaseClassName
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:YourNamespaceName"
mc:Ignorable="d"
x:Class="ChildControlClassName"
x:Name="ChildControlName"
d:DesignWidth="640"
d:DesignHeight="480"
>
...control XAML
</local:BaseClassName>
In your example woth the DataGrid, you would add the DataGrid into the control XAML, and set its ContextMenu property.