Using a sophisticated Winforms control like ZedGraph in WPF with MVVM design

I am building a WPF desktop application built on the MVVM pattern.

I want to display some graphs and decided to use the old ZedGraph library, as I am familiar with it, and there seems to be no better option at the moment (comment if there is)

I can put the graph control in my view with the following code:

    <WindowsFormsHost>
        <zed:ZedGraphControl x:Name="graphControl"/>
    </WindowsFormsHost>

However, I want to manipulate graph control a bit, set axes and data, etc. etc. Adhering to MVVM, I cannot invoke graph control from ViewModel, and I do not want to set a manipulation graph in the view code.

Is there a way to put a Graph Control object in a ViewModel, manipulate it there and still have a View view?

+3
source share
3 answers

IMO, I think this is not possible, since the basic control you are using is a Windows Forms control. As a workaround, you can write Custom WPF Control , which simply wraps Graphics Management using the WindowsFormsHost approach and provides much-needed properties for axis control, data, etc.

+3
source

To place a ZedGraph in a WPF window, look here .

+2
source

. , . , XAML . Behaviors ( ) xaml .

0
source

All Articles