Did I find a way to use WPF and WinForms? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Well, basically I was fooling around a little, experimenting etc. I came up with the idea of trying to mix WPF and WinForms, the reason for this idea is I had / found something that I wanted to utilize in the already existing WinForms project.
I first tried to import the .xaml files from the WPF project, and that failed miserably. It imported them as BlaBla.xaml.cs and it just didn't work out. Next I took a look at the "WPF User Control (XAML)" file in the "Add > New Item..." but that wasn't what I wanted. I wanted to work two windows, one in WPF one in WinForms, in same project in same ".exe".
So next I tried using another technique. I made a new "WPF User Control", however simply removed the existing code from the "user control" completely, and just copy-pasted the xaml code from from the WPF projects .xaml "MainWindow.xaml". After that I just renamed the user control to "MainWindow".
Then came the problem of showing the MainWindow.xaml from my existing Main.cs (WinForm window) per button click. I first tried Application.Run(new MainWindow()); however that failed miserably, so I tried the traditional
MainWindow MainWpf = new MainWindow();
MainWpf.Show();
I also tried stuff like...
MainWpf.btn_num_1.Content = "3"; (A button inside the xaml window)
I also attempted to control my WinForm window trough buttons inside the XAML window, everything working just fine.
Now, my question is. Is this supposed to work this easily and simplicity?

You can embed WPF controls in a WinForms application or WinForms controls in a WPF application, using a simple adapter. Because of this inherent symmetry, you can build hybrid applications, mixing controls from the other platform. Michael Sorens gives a practical guide to WPF / WinForms interoperability
https://www.simple-talk.com/dotnet/.net-framework/mixing-wpf-and-winforms/

Related

How to achieve beautiful user interface like website on windows form app? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have done a lot work on windows forms, In the past user interfaces were not important, but this time it is important. I want to create a windows form app that has a great interface, like a beautiful website.
shown one example below
Can I achieve this by any means in visual studio 2010? I don't have any experience of WPF, is it achievable there?
Yes, you can do this and much more in WPF (consider nice animations when you mouse-over or click items, or when tab changes, etc). Do not even try winforms, there are paid libraries, which can provide you with components to create rich user interface, but winforms is not flexible in any way by itself. In wpf you can achieve EXACTLY look you want.
Specifically to screenshot:
On top is some ItemsControl with items (DataTemplate) what has restyled checkbox (or vector graphics) and background bound to current item.
Below is ContentControl, which takes data template for current item (UserControl).
Actual content is simple restyled standard controls, it's very easy to make them looks like this.
Windows Forms is a legacy technology and does not provide you good tools to create your good looking custom controls. You need to work with low level API's to draw your controls like GDI+. If you are eager to learn, it is not that hard. It is indeed fun to work with GDI+ drawing shapes and painting them etc, but it will cost you a lot of time and it probably won't look too good.
Other than that if you want to stick with Windows Forms but develop your UI quickly, you can use DevExpress or Telerik libraries but they cost a lot of money.
As Sinatr said, the most common way is to go with WPF. You will access powerful tools like Blend and a modern API to create and customize your set of controls. You can still utilize DevExpress and Telerik control in WPF.

Best way to implement Drag and Drop Dashboard items in WPF? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to make a dashboard application, and I'm trying to create the layout rules for it and such and I'm not sure the best way to go about it. Originally I had a custom grid control, so I could add my custom controls to it easily enough. It worked in the sense that if you initially put stuff there, it was fine. But I want to implement a drag and drop facility in it and it kinda doesn't really like that.
The biggest annoyance is just detecting what position my mouse is on in terms of what row and column its in in the grid. So So I thought instead of a grid, I could use a Canvas, and just manually measure the grid slots. But I'm not sure if there's a better way. I'd like to mimic how on android, you can have widgets for the home screen and you can drag and drop them around the screen. I'd like it to just be like that essentially.
When dragging, I'd like have a green rectangle move instead of the thing and make it red if it overlaps with something else. Like I said, basically just like how android widgets work. I'd love some code examples since I'm new to WPF. If you've got any more general suggestions as well, that would be well appreciated.
Thank you!
check out blacklight and its newer version on github
the dashboard demo is what you need to look at.
You may have trouble to compile the code, but simply by removing the silverlight projects you can get the WPF demo running.
I know this is an old question. Creating this answer for anyone else who stumbles onto this question looking for a WPF Dashboard. I couldn't find any other Dashboards with dynamic widgets out in the wild so I created my own and I am sharing for anyone else who needs a better solution. This sounds like what Gentatsu was looking for in his initial question.
You can find it here:
https://github.com/DustinBryant/WpfDashboardControl

How to get Windows Explorer type look and feel inside my Application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I just got a project in which i need to create a windows explorer type application. I need to include various folders , Folders/Documents inside folders. And whatever folder/Document you select from left side, result will be shown in the right side panel.
As i am new to this all i don't know what to do and how to do. I have searched many sites but din't get any proper solution. So finally i am asking my question here. Please can you suggest how do i perform this using ASP.net with C#.
P.S. The application which is currently shown in image is a windows based application. And is developed in DevExpress.
There is no definitive answer to this, and I don't pretend to give one.
Keep in mind that making a clone of Windows Explorer is a daunting task. Instead the objective should be to create an application that anybody familiar with Windows Explorer can pick and use. Although, you need to start at the desired output, and see what is it you really need from this application - because not every feature will be viable.
Are you trying to make a virtual file manager? that looks like Windows Explorer? Then look for izwebfilemanager and look no futher. They have dedicate a good amount of time on that task.
Note: their online demo is long down - but get an screenshot:
If that is not what you are looking for, instead you want that appearance but provide a completely different functionality then, I think the real problem lies in the UI... you got to build it HTML + CSS + JavaScript.
Let's look at is that tree/list view at that left... I did look for some implementations...
This one in particular looks promising: BlueShoes TreeView
for something closer to our dear .NET you can try DevExpress Tree List (yet I think it is paid)
and also check 10 Javascript & CSS TreeView and Sitemap Plugins and Tutorials for a other alternatives.
I have been unable to find an already made solution for the icons area of the right, yet I am sure it can be done.
You will have to break down "Windows Explorer look and feel" to more specific requirements, I suggest to make a minimal version as an experiment to see what user actually would be doing with your app. Do you need multiple selection? Do you need drag and drop? etc...

Best Approach for a MDI Application in WPF? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am developing a WPF Application for a Shop.
So i have a MainWindow and all the rest will be Child.
Which is the best thing to Use as Child Window.
Window
UserControl
Window will be normal, it will be top on the MainWindow and if its UserControl it will be in a Canvas of a MainWindow.
So can anyone suggest me which is best to use out of this two.
I would recommend using UserControls for your child windows. This allows you to set up all of the "parent" controls on your main window and the children won't override them.
As a further suggestion, I would recommend looking into Caliburn Micro. That is a great framework for dealing with WPF windows and user controls.
To add a child UserControl to the parent window, I usually just add a ContentControl to my main form like so:
<ContentControl x:Name="ViewWindow" Margin="10" />
Just assign your child to that control and you will be fine.
I suggest to use a MDI framework like AvalonDock: http://avalondock.codeplex.com/
You will save a lot of time.
Please refer the website : http://wpfmdi.codeplex.com/
Like many things in life & coding: it depends :)
Window
When the new window has its own state & behavior
When there is little to no interaction/messaging between the main window & the pop-up window
User Control
When the state of the underlying main window is critical for the operation of the pop-up
When state changes need to be passed between the 2 windows
These are some of the design decisions which come to mind...
Consider to check MDIContainer. A similar project than MDI for WPF, but it gives you more freedom, since it does not force you to implement MDIChild window, interface or anything.
Child windows will be great for a desktop application when you are decided to use a parent - child window interaction, although I personally suggest you to use a frame in your main windows and use it to host multiple pages.
To learn more about navigation in WPF and silverlight you can visit this link
Using this approach will help you achieve the following advantages:
Lesser chance of memory leaks due to unattached event handlers.
Consistent design could be achieve without indicating style for child windows because you could set page backgrounds to transparent.
Users wont have a hard time locating which window has the focus when other programs were simultaneously used with the software you are building.
I also think that there are also allot of stuff you could consider in building this software but in the end of the day you are still the one who should decide on this matter.
This is only my suggestion and hope this helps :) .

How to develop unique GUI's in Visual Studio? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
All programs that I develop utilize the default Windows Design template:
Besides from changing the colors of the form, basically every program I write has this layout. I'm wondering how people create more custom GUI's. I tried looking it up on google but I clearly don't know how to phrase it to search. When I say custom GUI's I mean things like:
I assume it comes down to customizing what loads, but I don't know where to look, or what to research.
you should check out WPF. it frees you from the standard windows form
Your app 10 years from now:
Easily implemented in Winforms btw. FormBorderStyle is None, the Region and BackgroundImage properties and some judicious OnPaint() code.
try one of the following:
DotNetBar
Elegant UI
DevExpress
Take a look at Metro Framework. It is free, open source and famous one. I have recently used it and found it is very attractive. You can also find screenshots of the gui and code examples on the above mention link.
If it really must be a native desktop app then use WPF.. otherwise, with the rise of HTML5 and the mobile device, i can't see any reason not to build cross-platform web apps.
For WinForms, most of the custom controls can be created by overriding the OnPaint method of a control and performing your own custom painting.
You could also use WPF, and create your own themes and styles
Or you could download a 3rd-party control such as the ones mentioned by johntotetwoo.
I highly recommend you to use WPF instead, if it is possible for you to use Expression Blend, i highly suggest using Expression Blend for Designing UI(s), Storyboards(animations) and customizing UI(s) then you feel like you are walking in heaven :)
Then i suggest you to use templates or themes for WPF. Like zune theme, and if you are interested in Microsoft Office themes, the good news for you is there is an overflowing of themes like this, just google it!
but is suggest you to design your own controls if you are able to use Blend except for those situations that you see you can not do this really.

Categories

Resources