-1

I'm trying to use the oxyplot library in my WPF application. also, I'm using the MVVM pattern. one of the main parts of this pattern never uses "UI" specific in the "ViewModel" project. but when I look at the examples for this library, I see people are referencing oxyplot in their "ViewModels" by this: using oxyplot;. now I have this question. how should I use this library with the MVVM pattern? now I have installed the package in my "view" project by the NuGet package manager, should I do the same for my "ViewModel" project? I think this is not good because by installing it in "ViewModel" I'm breaking the MVVM pattern. but how can I access oxyplot classes from my "ViewModel"? Thanks in advance.

I was expecting to use the oxyplot by the MVVM pattern but now I'm mixed up :(

2
  • There are multiple Oxyplot nuget packages. Importing Oxyplot.Core in the ViewModel looks fine for me. Which classes from the other packages (e.g. Oxyplot.Wpf) do you need in the ViewModel code? Commented Dec 27, 2022 at 6:44
  • Yes, @KlausGütter I've checked them out and found the solution. thank you for your kind comment :) Commented Dec 27, 2022 at 14:35

1 Answer 1

1

your approach might work but I think you also need a value converter to convert between classes in "View" and "ViewModel" because they belong to different assemblies and also you may end up with namespace conflicts between "oxyplot" in "ViewModel" and "oxyplot" in "View" so you also have to do extra thing, for example, renaming the "oxyplot" namespace in "ViewModel" I think. The Best solution is to add "Oxyplot.Core" to your "ViewModel" and everything works fine and there is no need for extra work.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you . yes, I've encountered the problems you've mentioned. I tried your solution and everything is perfect now. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.