We are using a third party Chart control which was developed using WPF and that doesn't support MVVM. Now we need to add few more functionality and that should support Add/Remove feature on demand. We need to create Wrapper Chart control with new features and that should support MVVM. This dll/Module will be used by a few other Modules/Projects.
Note :
For every new feature we created Handler and composed the existing chart control. So we were able to support add/remove feature on demand.
Question :
How to support MVVM, is it for each FeatureHandler should i create ViewModel which wrap FeatureHandler(View) and looks like MVVM? Need clarification on this part.....
What do you mean dosen't support MVVM? I sounds fairly unlikely that a chart control developed with WPF dosen't expose properties in form of dependency properties. Do you have link to this third party chart control?
Related
I am new to MVVM and Caliburn.Micro and experimenting around with it.
Currently I am looking for a possibility to programmatically generate and add Controls, in this case Buttons, in a MVVM compatible way.
Is there a good way to dynamically add/generate controls and provide them functionality?
I would like to use a custom font for a Label in my WinForms project without installing the font. I found this as a solution, however it does not work since the FontStyle I want to use is Thin, which is not included in the System.Drawing.FontStyle enumerator.
Since I read instead that it should be quite easy in WPF to use such a custom font, I thought that a possible solution is to create a custom label (ThinLabel) in WPF and to host it in Winforms. Can you please instruct me on which is the proper way to create a custom label in WPF for this purpose? I read that in WPF controls can be customized in several ways (Styles, Data Templates,..) but I've no idea of which should be taken for this purpose. Please consider I've never used WPF so far.
In Order to implement WPF UserControls in Winforms you need to use and ElementHost
So if you want to create an WPF Label like you said in WPF you create a DLL project with your label inside it and reference it in your winforms project, after building you should be able to see a the UserControl with the label in the toolbox if not use an ElementHost
SCENARIO
I decided to work on WPF technology for my new application. This application has to be called on Menu click from a WinForms window. So I created a WPF UserControl Library and integrate it to display in parent WinForms Form using Element Host.
My Application
It contains 3 child usercontrols which are encapsulated inside another usercontrol with tabContent Control. I prefered this approach as firing events from Child UserControl and handling in WinForms (subscribing events) seemed painful.
My Question
Now facing the same painful task of accessing UserControl elements inside Winforms where I have created Data Manager class for proper project structuring reasons (UserControl should not contain Data Manager class-UI). Please guide me as to how to structure my project/how to subscribe events/access WPFUserControl elements inside WPF.
Take a look at the Messenger class of MVVM Light Toolkit (can also be used standalone). It helps decoupling your controls. The messenger works with a publish/subscribe pattern. Your WPF UserControls can publish objects, the WinForms Host can listen on those notifications. The exchanged messages (objects) are best placed in separate assembly, as they define the shared contract between WPF UC-library and WinForms application.
Create own TextBox, Button etc control as own control using User control in C# Windows application, is this good idea?
I wanted make consistency for through out the application. Suppose if I want to change the Textbox border color then all forms textbox updated with this changes. It's just an example.
Please suggest me.
I don't recommend using UserControl just for consistency. If application skinning is what you are after, look into WPF. It makes it relatively simple to skin an application (or even a window, or smaller groups)
Here is an article on skinning with WPF: http://www.codeproject.com/Articles/19782/Creating-a-Skinned-User-Interface-in-WPF
Another alternative, staying within Windows Forms, is creating a class that inherits from TextBox, and using that class throughout the application. The Factory pattern would work well here. You could even adapt it to multiple skins.
It's not a bad idea to provide custom controls that match your "User Experience" (UX). It really just depends on what you are trying to accomplish with your program.
I'd like to know if is there a way to "skin" a Form and every widget used inside it. Images should be on background and other elements shall be setup accordingly.
In short, a way to implement a way to display the same Form in different flavors (i.e.: theme and eyecandy UI).
DevExpress makes a WinForms control suite with an excellent selection of skins.
Telerik also provides WinForms components with theme support. I've used their library and it works fine.