C# Combine WinForm with WPF - c#

I created a grid splitted to two columns in WPF.
Then i need to access this grid in WinForm ( need to insert objects that created in WinForm inside the two columns).
How do i access the grid from WinForm?
Note: I have the handle of the window from the WPF:
ActiveMapCoreView = new MapCoreView(**Handle**, strPath);
Thanks! (:

If you want to mix winforms and WPF, you can host the WPF control in a winform using ElementHost Class.
You can find an exemple here

You can mix WinForms and WPF using an ElementHost. This walkthrough guides you through the process. This question and this article are worth looking at too.
On a related note, if your UI is predominantly WPF/WinForms it may be easier, and more consistent, longer term to port everything across into that format.

Related

How to add DataGridView control using VS2015?

I am totally new to programming in c# and have no previous experience with Object Oriented programming. I am teaching myself, so please I have many questions. I created a simple array that takes information from (STEP Text file) and displays it in a TextBox, now I am trying to put this information in Grid (like table) instead of showing them in a TextBox. I found Grid and Datagrid in the Toolbox window, but couldn't find DataGridView. I am using Visual Studio 2015. I would like to know:
How can I add DataGridView to my project?
Is there a simple code to put the information in a grid?
Since I am a beginner, please, be patient with me.
The reason is DataGridView is Windows Forms control and is available in Windows Forms project type only. You wont be able to use that in your WPF project. The equivalent in WPF is DataGrid.
As for the part regarding adding information in a grid, you will have to set the DataContext property of the DataGrid. For learning WPF, I would recommend to check out the two websites below:
https://wpftutorial.net/DataGrid.html
http://www.blackwasp.co.uk/WPFDataGrid.aspx

Create multi-view control in windows form

When using ASP.NET I was often using MultiViews,Is there a control that can be used in a C# Windows Forms Applications like MultiView, I try Tab control can help to do that but if any other control to make multi-view without using Tab control
There is no controls "from box", that you need. I can recommendate to you use WPF technology, if it's possible by your business requirement. WPF contains feature like Data templates selector, which can solve your problem.
I ran into this same problem and just implemented my own, using Panels

Own controls similar to TextBox in C# Windows 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.

Does a WPF Grid perform better than Winform's Table Layout Panel

I am currently working on an application that uses a Table Layout Panel to display a row of data. Each row contains a certain number of textbox and checkbox.
The number of rows present is usually quite big, making the loading and navigation of the Table Layout Panel extremely slow.
After some research, I've found that the TLP is one of the slowest Winform UI controls and I'd like to implement a WPF Grid instead.
My question is two-fold:
1) Does a WPF Grid perform better than a Table Layout Panel when it comes to a large number of rows ?
2) Is it possible to include WPF controls in an application that uses exclusively winform controls ? (The application uses .NET 3.5)
Thanks for your time and have a great day.
For performance, you'll have to do your own comparison. There are so many factors that could affect it that a well-written WinForms could be faster than a poorly-written WPF or vice versa. Just do a little prototyping and see if its an obvious win for you.
As far as using a little WPF in a mostly WinForms application, yes that is supported and can work well. Just put your WPF content in a WPF UserControl and then add an ElementHost to your form and host the WPF control inside that. Here's a lot more information:
Windows Forms – WPF Interoperability FAQ
Do you have background worker or thread for loading element into Table Layout Panel, if you have the problem with freezing?

How to skin UI using Forms?

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.

Categories