none
Export UserControl to XAML or another vector graphics format... RRS feed

  • Question

  • I am trying to export in images of some custom controls that have other children (other custom controls, shapes geometries, and text). I can create a bitmap of the custom controls using RenderTargetBitmap, but I want to be able to export in some vector graphics format too (XAML, WMF, EMF, etc.).

    I have seen some solutions using GDI+/Metafile, but I'm wondering if there is a direct way to do this from WPF. Is there some way I can convert the Visuals in my app to their vector graphic instruction lists so that I can export them in some vector format?

    Is it possible perhaps to write custom XamlWriter hooks for my UserControls that will output their Content visuals as Xaml?

    Related: is it possible to export core controls as vector graphics rather than their control class in Xaml? For example, can I take a Button object and export it as Xaml, not generating the output of XamlWriter, but which refer to the Shapes, gradients, and text/GlyphRun objects that make up the visual representation?

     

    Thanks for your thoughts.

    Sunday, July 3, 2011 8:52 PM

All replies

  • As you mentioned XamlWriter is the inbuilt class available to save any object as XAML, unfortunately that won't write whole visual.

    Not sure any custom library is available to meet your requirement. Probably analyzing of Snoop source code may help you.


    Ajosh Jose
    Monday, July 4, 2011 2:01 AM
  • Hi there,

    Snoop is source coded project and it use a native injector to hook with target windows. Do you have checked it out by any chances?


    Yves Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 9, 2011 8:31 AM
    Moderator