none
UIElement.Clip = Shape.RenderedGeometry RRS feed

  • Question

  • So I have something like this:

     

    Ellipse _ellipse;

    Canvas _canvas;

     

    _ellipse = new Ellipse();

    _ellipse.Stroke = Brushes.Blue;

    _ellipse.StrokeThickness = 4;

    _ellipse.Width = 100;

    _ellipse.Height = 50;

    _canvas = new Canvas();

    _canvas.Clip = _ellipse.RenderedGeometry;

     

    This Canvas is not rendered.

    Can anyone tell why?

    Tuesday, November 20, 2007 2:20 PM

Answers

  • It's not a right time to retrieve RenderedGeometry when the constructed Ellipse doesn't get rendered on to the screen, you can try something like this instead:

     

    Ellipse _ellipse;

    Canvas _canvas;

    _ellipse = new Ellipse();

    _ellipse.Stroke = Brushes.Blue;

    _ellipse.StrokeThickness = 4;

    _ellipse.Width = 100;

    _ellipse.Height = 50;

    _canvas = new Canvas();

    _canvas.Width = 100;

    _canvas.Height = 50;

    _canvas.Clip = _ellipse.RenderedGeometry;

    _canvas.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(delegate

        {

            _canvas.Clip = _ellipse.RenderedGeometry;

        }));

    _canvas.Children.Add(_ellipse);

    this.Content = _canvas;

    Friday, November 23, 2007 6:08 AM

All replies

  • It's not a right time to retrieve RenderedGeometry when the constructed Ellipse doesn't get rendered on to the screen, you can try something like this instead:

     

    Ellipse _ellipse;

    Canvas _canvas;

    _ellipse = new Ellipse();

    _ellipse.Stroke = Brushes.Blue;

    _ellipse.StrokeThickness = 4;

    _ellipse.Width = 100;

    _ellipse.Height = 50;

    _canvas = new Canvas();

    _canvas.Width = 100;

    _canvas.Height = 50;

    _canvas.Clip = _ellipse.RenderedGeometry;

    _canvas.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(delegate

        {

            _canvas.Clip = _ellipse.RenderedGeometry;

        }));

    _canvas.Children.Add(_ellipse);

    this.Content = _canvas;

    Friday, November 23, 2007 6:08 AM
  • Thanks, Marco.

    That did the trick.

     

    I get that the past tense in "Rendered".

    Friday, November 23, 2007 10:37 AM