You should consider posting us more code when you ask such specific questions.
Which event should I override to achieve this?
You seem to be asking for SizeChanged event:
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.sizechanged(v=vs.110).aspx
Any FE (FrameworkElement) has it therefore you will be able to subscribe to it.
And How do I gain access to the Grid defined in the DataTemplate?
In order to find something inside a template you could follow this constillation:
this.Template.FindName("theScrollViewer", this) as ScrollViewer
In my example I seek for a element with the name theScrollViewer
EDIT:
There is a great explaination here:
http://msdn.microsoft.com/en-us/library/bb613586(v=vs.110).aspx
EDIT2:
[TemplatePart(Name="PART_ContentHost", Type=typeof(FrameworkElement))]
TemplatePart is just an attribute that visual studio will use to show you how you should give names to your controls inside the template.
This method is doing the same as I showed you above.
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
anchor = Template.FindName("PART_ContentHost", this) as FrameworkElement;
}