質問

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

役に立ちましたか?

解決

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.

他のヒント

The two most likely issues are that your ContentControl is using a ControlTemplate that has no ContentPresenter (on one that is specifically using something other than the default Content property) or that it is using an empty DataTemplate as its ContentTemplate. You should be able to check either of these by inspecting at runtime.

I haven't quite figured this out, but it's something to do with the sizing. In Snoop it is showing a RenderSize of 0,0 and in inspector the actual height/width is also showing as 0 - you can see the red highlight inspector draws around the element is a small dot rather than a rectangle. I am guessing there's some Silverlight specific behaviour in the EMF control that doesn't port directly to WPF.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top