سؤال

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.

هل كانت مفيدة؟

المحلول

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.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top