Are there any situations where the content of a ContentPresenter
will be some object other than a UIElement
? Given that the field is declared as object rather than a UIElement
, it seems possible that there would be. However, I cannot think of any situations where it would be, or even if it would be valid.
ContentPresenter presenter = GetTemplateChild(PART_Presenter) as ContentPresenter;
UIElement myElement = (UIElement)presenter.Content;
myElement.SomeUIMethod(); // possible InvalidOperationException?