首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

wpf中如何创建圆角矩形标注框

2012-12-17 
wpf中怎么创建圆角矩形标注框?就是圆角的border,某条边上有个角的那种外框(用来放某人说了哪些话的那种框)

wpf中怎么创建圆角矩形标注框?
就是圆角的border,某条边上有个角的那种外框(用来放某人说了哪些话的那种框).因为根据条件边框要变色,用图片很麻烦.有没有办法用xaml或代码实现?
[img=http://storage.live.com/items/A843C5EBD9F7023D!10956][/img]
[最优解释]


    class DialogLabel : FrameworkElement
    {
        VisualCollection childs;
        DrawingVisual dv = new DrawingVisual();
        Brush bl = new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xff, 0x00));
        Pen p = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0xff, 0x00)), 1);
        public DialogLabel()
        {
            bl.Opacity = 0.5;
            p.Brush.Opacity = 0.5;
            p.Freeze();
            childs = new VisualCollection(this);
            using (DrawingContext dc = dv.RenderOpen())
            {
                List<PathFigure> points = new List<PathFigure>();
                PathFigure pf = new PathFigure();
                pf.StartPoint = new Point(0, 20);
                pf.Segments.Add(new ArcSegment(new Point(20,0),new Size(20,20),90,false,SweepDirection.Clockwise,true));
                pf.Segments.Add(new LineSegment(new Point(80, 0), true));
                pf.Segments.Add(new ArcSegment(new Point(100, 20), new Size(20, 20), 90, false, SweepDirection.Clockwise, true));
                pf.Segments.Add(new LineSegment(new Point(100, 60), true));
                pf.Segments.Add(new ArcSegment(new Point(80, 80), new Size(20, 20), 90, false, SweepDirection.Clockwise, true));
                pf.Segments.Add(new LineSegment(new Point(48, 80), true));
                pf.Segments.Add(new LineSegment(new Point(40, 100), true));
                pf.Segments.Add(new LineSegment(new Point(32, 80), true));
                pf.Segments.Add(new LineSegment(new Point(20, 80), true));
                pf.Segments.Add(new ArcSegment(new Point(0, 60), new Size(20, 20), 90, false, SweepDirection.Clockwise, true));


                pf.IsClosed = true;
                points.Add(pf);
                Geometry geo = new PathGeometry(points);
                dc.DrawGeometry(bl, p, geo);
            }
            childs.Add(dv);
        }
        protected override int VisualChildrenCount
        {
            get
            {
                return childs.Count;
            }
        }
        protected override Visual GetVisualChild(int index)
        {
            return childs[index];
        }
    }


[其他解释]
http://www.codeproject.com/Articles/27021/A-WPF-based-irregular-pop-up-window-demo
[其他解释]
该回复于2012-08-10 08:37:17被版主删除

热点排行