# Writing a simple Avalon app with C++/CLI

You cannot use XAML with C++/CLI, so you’ll have to hand-code your UI, as of now anyway. Anyway, here’s what you need to do to write a simple app.

### Step 1

Generate a new C++/CLI project, set the subsystem to Windows, set the entry point to main, and add the following references :

• System (if not already present)
• PresentationCore
• PresentationFramework
• WindowsBase

### Step 2

Add the following using namespace declarations to your cpp file :

using namespace System;
using namespace System::Windows;

### Step 3

Here’s your main method :

[STAThread]
int main(array<System::String^>^args)
{
return (gcnew Application())->Run(gcnew Window());
}

That’s all. Compile and run your app to see your first Avalon window in C++/CLI.

## 5 thoughts on “Writing a simple Avalon app with C++/CLI”

1. ash says:

*Completely* unrelated, but do u mind telling me how you get double quotes working in the code boxes?

I have code boxes but the double quotes are not selectable. It’s driving me nuts.

Regards,
Ash

2. Ash

Whay exactly is a code box?

3. ash says:

Sorry. The outlines above where you insert the code samples and color the text.

For example:
namespace

There is also a:
“d:\\abc\\def\\ghi\\nish”

used for coloring text (from the post on the SHCreateDirectoryEx API function)

I can copy ‘n paste a code snippet that has a string param from your webpage into Visual Studio with no problems.

However, when I try something similar on my webpage the quotes dont’ copy and paste correctly (they’re italic and not the ascii vertical kind). As a result, every code snippet pasted from my webpage into Visual Studio will have to have each double quote replaced.

I was just wondering how you got the HTML formatting for your string params working? It seems incredible trivial yet – for the life of me – I can’t get it working.

I hope that’s a little more clear?

Regards,
Ash

4. ash says:

OMG! I finally got it. I had to use the code tag in wordpress not the span tag.

Anyway, thx for your help. I feel kind of silly making a post about this and bothering you. I’m setting up my blog with WordPress also so I thought you might know.

Again, I feel silly for posting and am sorry for bothering you with this. If you could please delete these posts that would make me happy. =P

Thx and keep up the good work with the code project and ur site!

Regards,
Ash.