DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. One Intrepid C# Developer Explores a Metro App Using C++

One Intrepid C# Developer Explores a Metro App Using C++

Michael Crump user avatar by
Michael Crump
·
Feb. 16, 12 · Interview
Like (0)
Save
Tweet
Share
4.67K Views

Join the DZone community and get the full member experience.

Join For Free

I’m a C# guy through and through, but I have recently been exploring C++ . I decided to take you with me as I spend 10 minutes exploring the C++ Metro Templates included with Visual Studio 11. This blog post is written with my background in C#. I will try to point out the differences as I see them. We will look at C++ templates, solution explorer, some XAML and even some code-behind.

Let’s get started with templates.

The Visual C++/C# Metro Templates built-into VS 11

Visual Studio 11 has the following templates built-into it for Visual C++/C# projects:

image

image

The description of each project type is located below:

  • Application – A blank project using the Metro style framework.
  • Grid Application – A multi-page project for navigating multiple layers of content with item details displayed on a dedicated page.
  • Split Application – A project for navigating among a master list of items while viewing their details on the same page.
  • Unit Test Project – A Unit Test Project.
  • WinRT Component DLL – Template for a Windows Metro Style server DLL.
  • DirectX Application – (Only in C++) Template for a blank Windows Metro style application using DirectX.

The only thing to note here is the inclusion of a DirectX Application with the C++ Templates. Everything else is pretty much identical in terms of the template structure.

The Solution Explorer

If you take a look at the “Application Template” for C++ vs. C# then you will notice some differences.

imageimage

Looking at the C++ Solution Explorer in depth

  1. If you expand “External Dependencies,” then you will see a long list of header files along with other files needed to build a C++ Metro application. This is necessary for the application to compile as we also have standard references needed to use certain libraries in a C# application.
  2. The Resources Folder contains 4 PNG images that we are used to seeing inside of the Images folder in a C# Application.
  3. The only difference in the App.xaml and MainPage.xaml is that in the C++ application, it contains both a .cpp (C ++) and .h (header) file whereas the C# version only contains the .cs (C Sharp) file.
  4. The Package.appxmanifest exist in both projects and contains metadata that describes your app, including display name, description, logos, and capabilities.
  5. Finally, we get to the pch.cpp/pch.h files which are pre-compiled header files and are obviously not included in the C# application.

The other thing you might notice is that the C# application contains an AssemblyInfo.cs under Properties whereas the C++ version did not. This file consists of all of the build options for the project, including version, company name, GUID, compilers options, etc.

Looking at a simple “Hello World” Application – The XAML

A button and a TextBlock… it doesn’t get any easier than this. If the user clicks the button, then it displays “Hello World” in a TextBlock as shown below.

image

Thankfully, XAML is XAML – the following code snippet works regardless if you are using C#, VB or C++.

<Grid x:Name="LayoutRoot" Background="#FF0C0C0C">
              <StackPanel>
    <Button Content="Click Me" FontSize="24" Width="200" Height="60" Click="HelloButton_Click" />
    <TextBlock x:Name="DisplayText" FontSize="48" Foreground="White" />
     </StackPanel>
</Grid>

The Code Behind

You knew this part would be massively different, didn’t you? I hope so – we are talking about an entirely different language. :)

Below is a “Hello World” that works with the XAML included above in C#:

private void HelloButton_Click(object sender, RoutedEventArgs e)
{
    DisplayText.Text = "Hello World";
}

That same “Hello World” looks like the following in C++:

void HelloWorld::MainPage::HelloButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
    DisplayText->Text = "Hello World";

}

Look at the way the event handler is setup. Looks foreign right now doesn’t it? No worries, give this free e-Book a spin to convert your existing C# skills to C++.

Wrap-up

What did we learn in 10 minutes? We learned about several differences in C# and C++ Metro Applications. But the real challenge here isn’t learning the new templates, differences in solution explorer or XAML. It is that we need to learn the language. I’m not going to go into why I’m spending nights/weekends dabbling in C++, but I think learning native application development is a great way to go. I’ll probably expand on this post with a more in-depth article on building a complete application with C++ if enough people are interested. Until then - take care everyone!

 

Source: http://michaelcrump.net/the-first-10-minutes-of-a-c-developer-exploring-a-metro-application-using-c

 

csharp application app unit test Template

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • An End-to-End Guide to Vue.js Testing
  • Test Execution Tutorial: A Comprehensive Guide With Examples and Best Practices
  • Getting a Private SSL Certificate Free of Cost
  • The Beauty of Java Optional and Either

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: