C++: Working with Direct2D in XAML, today the Viewbox

C++: Working with Direct2D in XAML, today the Viewbox

  • Comments 1

XAML and Direct2 or Direct2D

In this case we will use the template provided with Visual Studio, this template is not found in the C# nor the VB template library.  In this case we are using the term template as in Document Template and not the C++ template.

The template isn’t all that easy to use if you are not a C++ wonk, so let’s take a look at it and add a viewport to it to show your interesting app

Get Started:

In C++ open the Direct2D App (XAML) as highlighted below:

 

image

Make a quick mod to the XAML

You HATE XAML?  Well of course you do, if you are a student the professors have been teaching you Forms for the past 7 years when XAML has been taking over the UI on Windows.  To show you how easy it is to use XAML, run your app and then snap it (ok, I changed the C++ phrase, not important right now, don’t get focused on that), but I changed the XAML to better demonstrate the snap effect:

image

 

So it looks like this:

image

And when snapped it looks like the following (the snap is on the left side of image, ignore the Visual Studio for now), note that we only see the words for one, two, three, and none of the other number words:

image

 

Now let’s add a Viewbox, not Viewport which is a keyword in XNA, not here, Viewbox, keep in mind that Viewbox can hold only one XAML thing, but that thing could be a grid that holds other things, in this case there is only a single textblock so you can use the Viewbox with that single thing.

image

Now try the snap:

Now you see the number words between one to eleven in tiny font.  Not necessarily what you want, but it does what I want: Shows you how to use the Viewbox.

Wait a minute, what about the C++ Generated text?  Why did that happen, well that is a story for another time. :)

 

image

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
  • You're wrong. I LOVE XAML.

    Thanks for your interesting article!

Page 1 of 1 (1 items)
Generic Content

Legal Note:

  1. The author, Sam Stokes, is an employee of Microsoft
  2. There is no guarantee that anything I write is correct, I do try to make sure that what I write is correct.
  3. Use anything written in this blog at your own risk
  4. Test what I write about before using the information
  • Sometimes posts will disappear because I realized that they really don't fit with the total chaos of what I write about
  • Links are tested and available on date of publication, what others do with their links are out of my control

Restrictions:

  • Whatever I write on this blog is unedited by management or anyone, which should be obvious from the randomness of the blog.  I simply write about things I like.
  • Microsoft does not restrict me in anyway, so I generallyblather about whatever I want to.
  • For personal reasons I will not write about:
    • Company confidential stuff, mainly because Microsoft is more transparent than any company I have ever worked for.
    • Other people unless they give me permission to write about them