Tech Off Thread

1 post

Saving a rendered bitmap from a WPF visual in MVVM.

Back to Forum: Tech Off
  • User profile image

    I've got an application that needs to write a sort of "screenshot" of a control to disk as a bitmap. I can use RenderTargetBitmap.Render() to render the visual and everything, but how do I do this from the viewmodel?

    The viewmodel receives a message (via the MVVMLight Messenger classes) that a bitmap needs to be saved, and in order to do that, it needs a reference to the visual. Which means a reference to the view, which ties my viewmodel to my specific view, which I don't want.

    Another idea would be to have the view render the bitmap and expose it to the view in some way via a OneWayToSource binding, but I have no idea how to tell it when to update via the viewmodel.

    Anyone got any ideas?

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.