3

I want to create a branch of thumb pictures for my UI, and I tried to do it in this way:

RenderTargetBitmap renderer = new RenderTargetBitmap(WIDTH, HEIGHT, dpiX, dpiY,   PixelFormats.Pbgra32);
renderer.Render(vbox);
renderer.Freeze();

"vbox" is my UIElement, it is created in a background thread and I need to render it to a bitmap to show it in main UI thread. I won't use "vbox" anywhere after finishing rendering it to bitmap.

Those codes worked but then I found I wasn'6t satisfied with it because it looked bad if I enlarge the size of thumb picture.

I hope I can use something like vector graphic, so I tried to do it in this way:

        var visualBrush = new VisualBrush(vbox);
        visualBrush.Stretch = Stretch.Uniform;
        visualBrush.Freeze();

Of course this didn't work because I couldn't freeze a visual brush with it's Visual property assigned any value other than Null.

Can anyone help me out? Thank you very much.

cheers

Alex

woodheadz
  • 31
  • 3

1 Answers1

0

You can use (de)serialization to create individual copy of VisualBrush. See this answer

Community
  • 1
  • 1
karel
  • 1,297
  • 1
  • 10
  • 22