public CanvasXmlWriter( TextWriter writer, SerializationSettings settings )
        {
            Contract.RequiresNotNull( writer, "writer" );
            Contract.RequiresNotNull( settings, "settings" );

            myWriter = writer;
            myIdTransformation = CreateIdTransformation( settings );
        }
 private static IIdTransformation CreateIdTransformation( SerializationSettings settings )
 {
     if( settings.RewriteIds )
     {
         return new RewriteIdTransformation();
     }
     else
     {
         return new IdentityIdTransformation();
     }
 }
        public void CopyToClipboard( CanvasContent content )
        {
            using ( var writer = new StringWriter() )
            {
                var settings = new SerializationSettings();
                settings.RewriteIds = true;

                var serializer = new CanvasXmlWriter( writer, settings );
                serializer.Serialize( content );

                Clipboard.Clear();
                Clipboard.SetData( DataFormats.Xaml, writer.ToString() );
            }
        }