Yes. You need to override MeasureOverride in your external WPF control, convert the size from WPF coordinates to device coordinates, and update ElementHost.Size .
Since you already subclass Expander :
- Override the
MeasureOverride - After calculating the measurement, use
PresentationSource.From(visual).CompositionTarget.TransformToDevice.Transform(point) to get the device coordinates - Update
ElementHost.Size .
For this instance of the Expander subclass, this requires a pointer to an ElementHost .
A more general solution would be to create a new class to handle synchronization. This will be a subclass of FrameworkElement and will be a direct descendant of ElementHost .
Ray burns
source share