Search code examples
c#wpfmetafile

ContentControl WPF does not display Content


I've convertet the Project from https://silverlightcontrib.codeplex.com/ to WPF (github https://github.com/jogibear9988/silverlightcontrib) to get EMF/WMF metafile support in WPF.

Now my Probjem is, the EMF Class uses a ContentControl for displaying it's Content. The Content is also set, but nothing is displayed. If I check it in WPF-Inspector, I see that the EMF Control has it's Content listed in the "Logical-Tree" but not in the Visual! Can anyone help me out with this?

The current state of the Fork is Online (if anyone will look at the Code!)

If I look in snoop everything seems alright:

enter image description here

You see, the Content Presenter has a Content set and Filled, but it does not get into the Visual Tree...

Here is the Logical Tree from WPF Inspector: enter image description here

And here the Visual: enter image description here


Solution

  • I am not very familiar with Silverlight, but in WPF when you override MeasureOverride(...) and ArrangeOverride(...) you have to measure and arrange the contol's children so they can measure and arrange their children and so on. In your case, you have to include calls to base.MeasureOverride(...) and base.ArrangeOverride(...) in the Emf class that inherits from ContentControl.