WPF - XAML - C # - C ++ - So Confused

I hope someone can help, I am new to programming and bought a book (Visual Basic - Step by Step), I made good progress until I read an article on the Internet about the Windows Presentation Foundation (WPF) - apparently this is the future.

I read on Xaml and I find the syntax is extremely difficult to understand, for example, I encoded in the following format:

texbox1.text = "Hello World!" 

However, the manuals I read on Xaml show that the encoding in the .cs file is as follows:

 <Grid> <TextBlock Text="Hello World!" /> </Grid> 

I am confused about what โ€œlanguageโ€ I should learn!

Hope someone can shed some light on this.

Thank you very much

+4
source share
4 answers

There are many aspects of programming, and this can certainly be overwhelming for a beginner quickly. First, clarify a few terms:

VB (Visual Basic), C # and C ++ (mentioned in your title) are high-level programming languages. Assuming that when you, for example, Visual Basic, you mean VB.NET (which is likely if the book you are reading does not age ...), VB and C # are both languages โ€‹โ€‹that you can use with Microsoft .NET Framework , a set of libraries and tools for creating (primarily Windows) applications.

(C ++, meanwhile, is a slightly lower level language that is not directly related to .NET. This requires an understanding of some of the concepts that .NET languages โ€‹โ€‹hide from you, such as pointers and memory management .)

Now the programming languages โ€‹โ€‹mentioned above are not tied to a specific presentation technology - there are many ways to create interactive programs that display output for users and accept input regardless of the language you use. However, .NET languages โ€‹โ€‹are commonly used in conjunction with several powerful tools that the .NET Framework provides for creating graphical applications:

  • Among the simplest methods of the user interface, you can create a console program that takes input and produces text on the system console. Nothing special here.
  • Windows Forms - Originally provided by Visual Basic versions for pre-.NET, it is a venerable API for the Windows native user interface. It is controlled mainly by Form objects that contain controls and are controlled by user events. Here is the primer.
  • WPF (Windows Presentation Foundation) is a newer technology than Windows Forms. It is used in conjunction with the XML-like file format you specified above called XAML (Extensible Application Markup Language) , which allows you to create user interfaces by quickly declaring a hierarchy of visual objects. The learning curve for building WPF applications is slightly higher (in my opinion) than for Windows Forms, but it is a more universal technology that better supports several good design templates (this is manual, I know, but honestly, for now).

So, to eliminate some confusion:

  • The programming language that you use and the structure for building graphical user interfaces are two separate options.
  • Both VB.NET and C # can be used to write basic logic for Windows Forms or WPF applications.
  • WPF, the graphics subsystem, and XAML, the declarative markup language, are not the same thing, but they are used hand in hand with each other.
  • When creating WPF controls, you will have a file containing XAML (with the .xaml index), which is attached to the file with the code-behind code containing C # (with the extension .cs) or VB (with the extension .vb), depending on your chosen language.

In general, a .NET programmer (which is an easy example for me, as I am one of them) will use either VB or C #, depending on what it is most convenient with (or what the team is entrusted to them!) From the point of view of beginners, especially, they have different syntaxes, but are functionally equivalent. I personally prefer C # for its similarity with languages โ€‹โ€‹(Java and C) in which I learned to program.

Now, regardless of the language, the programmer then selects the appropriate user interface technology for the project. For graphical applications running on Windows, I think WPF is a technology that needs to be beaten (especially because it is very similar to Silverlight, which can be used to target the Internet and Windows Phone).

I hope that at least the process of finding out what is a very complex but navigable topic will begin! I already contacted him once above, but go to the Microsoft Beginner Developer Center as another resource that will help you get on your feet. Good luck

+8
source

The way you encoded and the xaml markup code does the same. The main reason for the existence of XAML is to allow user interface designers to work with the user interface using XAML, and later programmers will link business functionality using C # or XAML. XAML is mainly used in WPF, but languages โ€‹โ€‹like C #, VB can be used for more things. As for which languages โ€‹โ€‹to learn, it all depends on your interests and your work.

+1
source

djacobson answers 90% of what I was going to write ... so this is just a small addition to this answer giving my personal advice.

If you are just starting to learn programming ... actually it doesn't really matter where you start, what language you choose. It looks like you started learning Visual Basic. I mainly write in C # ... but for the most part ... they can do the same, and both are good options to start learning programming.

For your first two projects, just create console applications that actually don't have a user interface other than the command line (console).

When you go ahead and want to start building GUI applications, you can look in XAML (WPF if you are creating a Silverlight desktop application if it is a web application).

You still write your business logic code using Visual Basic or C #, XAML is just a way to determine how your GUI will look and behave using XML habit and not older technology like Windows Forms .

I will be the first to say that I absolutely love WPF and XAML, but I really feel that it is best for you to first learn the basics of the language of your choice, and then work with the user interface technologies.

+1
source

Since over the past 2 years I have been working on WPF, and even I was empty when it came to WPF. I would prefer C # in C ++ and yet you can find solutions for each language. But it is up to you, which is convenient for you.

0
source

All Articles