I get a full ellipse not the intersection between the two. What is wrong?
<Canvas x:Name="mainCnavs">
<Ellipse x:Name="ellipse" Width="100" Height="50" Canvas.Top="100" Canvas.Left="300" Fill="Transparent" Stroke="Red" StrokeThickness="3"/>
<Ellipse x:Name="ellipse1" Width="100" Height="50" Canvas.Top="100" Canvas.Left="250" Fill="Transparent" Stroke="Red" StrokeThickness="3"/>
</Canvas>
public partial class MainWindow : Window
{
CombinedGeometry g;
Path p;
public MainWindow()
{
InitializeComponent();
mainWindow.Loaded += new RoutedEventHandler(mainWindow_Loaded);
}
void mainWindow_Loaded(object sender, RoutedEventArgs e)
{
g = new CombinedGeometry(ellipse.RenderedGeometry, ellipse1.RenderedGeometry);
g.GeometryCombineMode = GeometryCombineMode.Intersect;
statusBar.Text = "top left " + g.Bounds.TopLeft.ToString() +" bounds.size " + g.Bounds.Size + " bounds " + g.Bounds.ToString();
p = new Path();
p.Data = g;
p.Fill = Brushes.Green;
mainCnavs.Children.Add(p);
}
}
If I change the ellipse to a rectangle, and do a union is giving the two shapes overlapped. It behaves as if the two geometries have no positioning, is this because I am using the rendered geometry and it has no position associated with it? Then what is another way then to get the geometry of the shape?