日期:2014-05-20  浏览次数:21421 次

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));