問題があります
AdornerLayer AdornerLayer = AdornerLayer.GetAdornerLayer (layout);
このメソッドは常に null を返します。
私は何を間違っていますか?
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Layout layout = new Layout();
layout.Background = Brushes.White;
layout.ClipToBounds = true;
layout.SnapsToDevicePixels = true;
layout.Width = 4965; layout.Height = 3515;
AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(layout);
adornerLayer.Add(new LayoutAdorner(layout));
}
}
public class Layout : Canvas
{
public Visual GetVisualChildAtPoint(Point point)
{
return VisualTreeHelper.HitTest(this, point).VisualHit as Visual;
}
}
public class LayoutAdorner : Adorner
{
public LayoutAdorner(UIElement adornedElement) : base(adornedElement) { }
protected override void OnRender(DrawingContext drawingContext)
{
}
}