Search code examples
silverlightwindows-phone-7pathgeometry

EllipseGeometry is not rendering in Silverlight


I'm trying to draw a circle in WP7 Silverlight using EllipseGeometry instead of Ellipse. The sample XAML in MSDN does not display anything on the canvas in Visual Studio. If I run the app, it does display in the emulator.

<Canvas> 
    <Path Fill="Gold" Stroke="Black" StrokeThickness="1">
        <Path.Data>
            <EllipseGeometry Center="50,50" RadiusX="50" RadiusY="50" />
        </Path.Data>
    </Path> 
</Canvas>

Any ideas what is happening?


Solution

  • For some unclear reasons, you should assign Width and Height.

      <Canvas>        
            <Path Width="100" Height="100" Fill="Gold" Stroke="Black" StrokeThickness="1">
                <Path.Data>
                    <EllipseGeometry Center="50,50" RadiusX="50" RadiusY="50" />
                </Path.Data>
            </Path>
        </Canvas>
    

    In blend, you will not have this issue.