show-notice
hide-notice

Tuesday, 16 July 2013

Combining Shapes with GeometryGroup in Silverlight


Introduction  

I will explain Combining Shapes with GeometryGroup in Silverlight Description

Description


The simplest way to combine geometries is to use the GeometryGroup and nest the other Geometry-derived objects inside. Here’s an example that places an ellipse next to a square.

The effect of this markup is the same as if you supplied two Path elements, one
with the RectangleGeometry and one with the EllipseGeometry (and that’s the same as if you used a Rectangle and Ellipse shape instead). However, there’s one advantage to this approach. You’ve replaced two elements with one, which means you’ve reduced the overhead of your user interface. In general, a page that uses a smaller number of elements with more complex geometries will perform faster than a page that has a large number of elements with simpler geometries. This effect won’t be apparent in a page that has just a few dozen shapes, but it may become significant in one that requires hundreds or thousands.  


Example


<UserControl x:Class="VC35.Page"
   
xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   
xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
   
xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
   
xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
   
mc:Ignorable
="d"
   
d:DesignHeight
="300" d:DesignWidth="400">
      <Grid
x:Name
="LayoutRoot" Background="White">
          
<
Path
Fill="Yellow"
Stroke
="Blue" Margin="5"
Canvas.Top
="10" Canvas.Left="10" >
                
<
Path.Data>
                      
<
GeometryGroup>
                            
<
RectangleGeometry
Rect="0,0 100,100"></RectangleGeometry>
                            
<
EllipseGeometry
Center="150,50"
RadiusX
="35" RadiusY="25"></EllipseGeometry>
                      
</
GeometryGroup>
                
</
Path.Data>
          
</
Path>
      </Grid>
</UserControl>

CS

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace VC35

{

    public partial class Page : UserControl

    {
        public Page()

        {

           
InitializeComponent();

        }

    }

}


SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com