9 Replies - 786 Views - Last Post: 05 August 2012 - 05:07 AM Rate Topic: -----

#1 Codebug  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 244
  • Joined: 11-October 09

Question about C# GUIs

Posted 02 August 2012 - 05:10 PM

I'm a prospective C# programmer with a background in Java and C++. My question is: how are GUI's coded in C#? In the case of Java GUIs, the majority of people here highly suggest writing all GUIs by hand and avoiding GUI builders because the code they produce isn't very human readable. Should GUIs in C# be written completely by hand as well or are there "GUI builders" that produce legible code?

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: Question about C# GUIs

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3666
  • View blog
  • Posts: 11,497
  • Joined: 05-May 12

Re: Question about C# GUIs

Posted 02 August 2012 - 05:38 PM

For projects that I care about, and I don't have to work with other people in a team, I personally hand write my GUI's for WinForms and for WPF. If I have to work with a team, then I'll grudgingly use the VS2010 Designer, unless the other team members also believe in handwriting forms (which is not very likely). As for WPF, if it's complex UI, use the VS2010 Designer or Blend to get all the pixel counting and frame timing done right. I feel that people are lying though if they say they never touch the XAML directly.
Was This Post Helpful? 1
  • +
  • -

#3 Codebug  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 244
  • Joined: 11-October 09

Re: Question about C# GUIs

Posted 02 August 2012 - 05:47 PM

Thanks for the reply. A couple of questions: Do you know of any resources that discuss hand writing GUIs in C#? Also, what are "WinForms", "WPF", and "XAML"?

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3666
  • View blog
  • Posts: 11,497
  • Joined: 05-May 12

Re: Question about C# GUIs

Posted 02 August 2012 - 06:07 PM

WinForms is a thin wrapper around the Win32 controls, in general. There are actually some WinForms controls that have been written from scratch in C# like the DataGridView. These controls can be found in the System.Windows.Forms namespace. Getting Started with Windows Forms

WPF, otherwise known as Windows Presentation Framework is MS's next generation of GUI for the desktop. It shares many similarities with Silverlight which is MS's response to Flash. Although MS never says that WPF will deprecate WinForms, I think that it's mostly a politically correct answer to not piss off people who invested heavily in WinForms. I think that it's pretty telling the VS2010 was re-written in WPF rather than WinForms. WPF in Visual Studio

XAML is declarative way to creating UI. It's a lot like HTML where you stick in the controls and layout directly. I think that MSDN makes a far better job of explaining it here: http://msdn.microsof...y/ms752059.aspx
Was This Post Helpful? 1
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,500
  • Joined: 29-May 08

Re: Question about C# GUIs

Posted 02 August 2012 - 08:21 PM

Don't be so quick to judge the GUI designer in Visual Studio.
You may be surprised how human readable the code produced is.

Simple WinForms Hello World button
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1 {
  public partial class Form1 : Form {
    public Form1() {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e) {
      MessageBox.Show("Hello World!");
    }

 
  }
}




GUI Code.
Spoiler



Extra in VS2012 the XAML GUI designer is actually the GUI Blend designer.

This post has been edited by AdamSpeight2008: 02 August 2012 - 08:24 PM

Was This Post Helpful? 1
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5678
  • View blog
  • Posts: 12,213
  • Joined: 02-June 10

Re: Question about C# GUIs

Posted 03 August 2012 - 04:53 AM

View PostCodebug, on 02 August 2012 - 06:47 PM, said:

Also, what are "WinForms", "WPF", and "XAML"?


Suggestion: Go to a bookstore. Browse the books on the subject. The public library probably has several too. We simply don't have the resources to mentor all 500,000 members from Day one - let alone another 2 million prospective people that are PRE day one.

The fact that you asked this, rather than attempting any type of search concerns me. You have heard of search engines like Google and Bing, right? Its not that I want to shuffle you off to some other site. But I think it speaks to someone's work ethic when they can't be bothered to try to do any research on their own. Most people, especially the experts here, respond better to this case:

Quote

Thanks for those tips. I researched "WinForms", "WPF", and "XAML" and read a bunch about each one. WInForms and WPF both seem to have strong positives and negatives. Based on your experience which do you think is better for a rookie to learn and why?

than they would to this case

Quote

Uh... What are those dude?





First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover. Do a couple hundred on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.

Then later you can start architecting your own simple stuff. Build a calculator. Build a DVD library program. Etc. Stuff that doesn't involve the complexity of a game. Then move up to games.



There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

Quote

Where do I start?


You start by learning a coding language FIRST.
Learn to plan before you type.
THEN you start designing software with a purpose.


If this sounds like you

Newbie/Rookie said:

I have a little programming experience but I need to write ...
read this section
Spoiler


Otherwise, you can just jump to the resources here:
Some of the tutorials below are for C# or Java not C, C++, VB.NET [...]. But the conceptual stuff of classes, object oriented design, events etc. are not language specific and should give you enough guidance in theory of program development for you to be able to look-up specific code example in your chosen coding language.



Resources, references and suggestions for new programmers. - Updated Mar 2012
Spoiler

Was This Post Helpful? 0
  • +
  • -

#7 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Question about C# GUIs

Posted 03 August 2012 - 07:42 AM

View PostSkydiver, on 02 August 2012 - 07:38 PM, said:

For projects that I care about, and I don't have to work with other people in a team, I personally hand write my GUI's for WinForms and for WPF. If I have to work with a team, then I'll grudgingly use the VS2010 Designer, unless the other team members also believe in handwriting forms (which is not very likely). As for WPF, if it's complex UI, use the VS2010 Designer or Blend to get all the pixel counting and frame timing done right. I feel that people are lying though if they say they never touch the XAML directly.


You're by and far the minority in the C# developing world if you hand-code your forms. In Java you'd be right there with everyone.

Regardless, I'm hoping traditional windows forms just dies eventually. WPF is great, and now we have Metro to deal with as well.
Was This Post Helpful? 1
  • +
  • -

#8 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3666
  • View blog
  • Posts: 11,497
  • Joined: 05-May 12

Re: Question about C# GUIs

Posted 03 August 2012 - 05:14 PM

The other thread is a perfect example of where a hand written GUI would have been much easier. If I didn't have to play footsies with the Designer, simply changing 1 or 2 lines of code to make the tab class derive from UserControl, and I'm done. Now, he'll have to go recreate the contents of his Form in a UserControl.

[All my past experiments of simply doing a cut and paste of code from a Form to a UserControl (or vice versa), seem to initially work, but a few days or a week later VS gets into a bad state and seems to complain about being unable to load the new class that I had pasted code into, and I eventually have to recreate the destination control or form again from scratch.]

This post has been edited by Skydiver: 03 August 2012 - 05:14 PM

Was This Post Helpful? 1
  • +
  • -

#9 Codebug  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 244
  • Joined: 11-October 09

Re: Question about C# GUIs

Posted 04 August 2012 - 10:29 PM

View PosttlhIn`toq, on 03 August 2012 - 05:53 AM, said:

Suggestion: Go to a bookstore. Browse the books on the subject. The public library probably has several too. We simply don't have the resources to mentor all 500,000 members from Day one - let alone another 2 million prospective people that are PRE day one.

The fact that you asked this, rather than attempting any type of search concerns me. You have heard of search engines like Google and Bing, right? Its not that I want to shuffle you off to some other site. But I think it speaks to someone's work ethic when they can't be bothered to try to do any research on their own.


Mr. tlhIn`toq, I value the wisdom and advice of the experts on this forum far more than other sources that have been authored by someone who may or may not have a clue as to what they're talking about. I trust the experts here and I have never been led astray by them. That is the reason why I don't search other places first.

You don't know me and my work ethic is nothing like what you have insinuated. I was under the impression that this site was for programmers of all skill levels and backgrounds.

If my novice questions and forum etiquette have angered or frustrated you in any way, I am truly sorry and I apologize. I can assure you that I will not make this mistake again.

Good Day

This post has been edited by Codebug: 04 August 2012 - 10:29 PM

Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5678
  • View blog
  • Posts: 12,213
  • Joined: 02-June 10

Re: Question about C# GUIs

Posted 05 August 2012 - 05:07 AM

View PostCodebug, on 04 August 2012 - 11:29 PM, said:

View PosttlhIn`toq, on 03 August 2012 - 05:53 AM, said:

Suggestion: Go to a bookstore. Browse the books on the subject. The public library probably has several too. We simply don't have the resources to mentor all 500,000 members from Day one - let alone another 2 million prospective people that are PRE day one.

The fact that you asked this, rather than attempting any type of search concerns me. You have heard of search engines like Google and Bing, right? Its not that I want to shuffle you off to some other site. But I think it speaks to someone's work ethic when they can't be bothered to try to do any research on their own.


Mr. tlhIn`toq, I value the wisdom and advice of the experts on this forum far more than other sources that have been authored by someone who may or may not have a clue as to what they're talking about. I trust the experts here and I have never been led astray by them. That is the reason why I don't search other places first.

You don't know me and my work ethic is nothing like what you have insinuated. I was under the impression that this site was for programmers of all skill levels and backgrounds.

If my novice questions and forum etiquette have angered or frustrated you in any way, I am truly sorry and I apologize. I can assure you that I will not make this mistake again.

Good Day


Kid, chill out and grow up a bit. Just because someone isn't your cheer squad doesn't mean they are insulting you. Just because something they write isn't saying "You're perfect, you can achieve anything" doesn't mean the help is worthless. Sometimes the best advice can be the advice that's hardest to hear. Your friends, family and clergy can bolster your self esteem. We will tell you the truth. Don't you think it is worth knowing that at least one person interpreted your comments/actions in a certain way? Doesn't that make you wonder if someone else (like a prospective employer) might see it the same way? Nobody is saying you have to agree with it. But I do suggest you consider the fact that not everyone will always agree with you. You are right: I don't know you or your work ethic. I only know what you present here, a totally clean slate where everyone is equal with no preconceived notions. Just like a job interview you are competing against others based on nothing but your written words. I tried to give you a different perspective on your post and give you some insight into how it could be taken and some advice on how to have it taken better. And you're mad about that?

Quote

Most people, especially the experts here, respond better to this case:

Quote

Thanks for those tips. I researched "WinForms", "WPF", and "XAML" and read a bunch about each one. WInForms and WPF both seem to have strong positives and negatives. Based on your experience which do you think is better for a rookie to learn and why?


than they would to this case

Quote

Uh... What are those dude?


This site is for programmers of all levels. Nobody said otherwise. But you have to recognize there are over 500,000 members and a core group of about 50 experts. That's a student:teacher ratio of 10,000:1. Nothing incriminating about that just simple math. It is simply not possible for us to hand-hold every new member through every introductory question that is well covered in MANY books and many on-line tutorials. There is a certain amount of effort the student has to take on as their own responsibility to research.

The experts here are volunteers. The reality of human beings is that you need to compete for their attention. I for one help those that make an effort. Someone that does a bit of research on their own and comes back with smart questions is someone I want to help. I'll spend countless hours with one rookie that shows that kind of promise. The kid that just says "tell me more", "what does that do", etc. without bothering to do any experimenting on their own, without trying to do any research of their own is not going to make it in this industry. I don't see a reason to spend my limited free time on a lost cause. I won't write the same day-one advice over and over in 100 threads. I will write a tutorials (or several) so it is explained well.

I won't spend time more time on someone else than they are willing to invest in themselves.
And that is how I interpret someone that can't bother to do their own basic research and reading and forming of their own thoughts: They won't invest the time in themselves.

This post has been edited by tlhIn`toq: 05 August 2012 - 05:10 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1