Question

I need a way to dynamically retrieve (not knowing what type of frameworkElement), the content/items presenter size and offset from the owner's edges in any form.

I need to create an adorner that covers the content area of a control.

Was it helpful?

Solution

Use the VisualTreeHelper to identify the ContentPresenter/ItemPresenter from the object if it exists.

Use the following code to get an offset:

presenter.TransformToVisual(control).Transform(new Point(0,0));

Call on presenter whatever desired properties that will give you size (Actual[Height/Width], etc.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top