5

I am using an UserControl that contains the Canvas. As child of the canvas there is content control with adorner. Why the adorner is not visible perhaps the adorner layer is ceated. Everything is created and attached. The adorner layer is very high in a visual tree. The adorner layer is placed outside the UserControl.

I know that is created because I implemented basic movement mechanism that works but the decorator never shows up.

What has to be done to show the decorator?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Patrik
  • 1,286
  • 1
  • 31
  • 64
  • 1
    As far as I see from http://msdn.microsoft.com/en-us/library/ms743737.aspx the Adorner is usually implemented inside the method override OnRender. Is this what your are doing? – Klaus78 Mar 27 '12 at 08:07
  • 1
    Yes I am. I finally found why. When I added the merged resource dictionary to the MainWindow of the application and not only into resources of the custom usercontrol then the adorner finally show up. – Patrik Mar 27 '12 at 20:37
  • @patrik i am facing same issue , please explain more... – J R B Jan 16 '15 at 06:26
  • I do not know what is you application architecture but I managed to move my entire resource dictionary to the window that contains all object and adorners I managed to resolve the visibility. Previously I had the resources of the adorner assigned to the UserControl. When I moved everything to upper layers (the Window) I got the adorner on the screen. – Patrik Jan 16 '15 at 13:27

1 Answers1

5

A WPF window by default has an AdornerDecorator but a usercontrol does not. So you just have to wrap your Canvas with an Adorner decorator in your usercontrol.xaml:

<AdornerDecorator ClipToBounds="True">
            <Canvas x:Name="DesignerCanvas"
            ClipToBounds="True"
            SnapsToDevicePixels="True"/>
</AdornerDecorator>

More info: https://social.msdn.microsoft.com/Forums/vstudio/en-US/43a2565d-df21-4cf3-aa2a-240d67662945/please-help-me-resolve-a-mistery-with-resource-adorner-and-usercontrol-a-bug?forum=wpf

user3094988
  • 51
  • 1
  • 3