Пример #1
0
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            foreach (AlignPart it1 in w_parts.Items)
            {
                var cp1 = (ContentPresenter)w_parts.ItemContainerGenerator.ContainerFromItem(it1);
                var bi1 = VisualTreeHelper.GetChild(cp1, 0) as ToggleButton;
                var r1 = new Rect(bi1.DesiredSize);
                var pt1 = bi1.TransformToAncestor(this).Transform(r1.BottomCenter());

                foreach (var it2 in it1.AlignedParts)
                {
                    var cp2 = (ContentPresenter)w_alignwith.ItemContainerGenerator.ContainerFromItem(it2);
                    var bi2 = VisualTreeHelper.GetChild(cp2, 0) as Button;
                    var r2 = new Rect(bi2.DesiredSize);
                    var pt2 = bi2.TransformToAncestor(this).Transform(r2.TopCenter());

                    dc.DrawLine(new Pen(Brushes.Black, 2), pt1, pt2);

                }
            }
        }