Multitouch "Hello World" program

Start Visual Studio and create a new WPF project and name it "MultitouchHelloWorld".

CreateWpfProject.png

Add reference to Multitouch.Framework.WPF.dll assembly.

AddReference.png

In Window1.xaml add a new namespace: xmlns:mt="http://schemas.multitouch.com/Multitouch/2008/04", and change root object <Window> to <mt:Window>. Don't forget to close it with </mt:Window>. Then open Window1.cs and change Window1 base object from Window to Multitouch.Framework.WPF.Controls.Window_.
Your xaml should look like this:

UsingMultitouchWindow.png

and cs file like this:

UsingMultitouchWindowCS.png

Now add a TouchablePanel as a child of Grid and TextBlock as a child of TouchablePanel. Set the Text property of TextBlock to "Hello World!!!".
Let's make this text bigger, so we could easily touch it. Set FontSize property to 72, FontWeight to Bold and make Foreground White and Background LightBlue.

FinalProgram.png

Our program is ready. Before you start it, you have to start multitouch service. For example by executing Multitouch.Service.Console.exe.
Now hit F5 to start the program. Your program will look like this and you can touch the text and move and rotate it around.

ProgramRunning.png

Let's make our program a little more useful. Replace TouchablePanel with ItemsControl and set its ItemsPanel to TouchablePanel. Now bind ItemsSource to Photos property with {Binding Photos}.

ItemsControl.png

Now let's write some code. Open Window1.cs file. And add a new DependencyProperty Photos of type ObservableCollection<string>. In constructor, before InitializeComponent is executed, set DataContext to this. Now override OnInitialized_ method and add this code:

foreach(string file in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "*.jpg").Take(5))
{
	Photos.Add(file);
}


It will take 5 pictures from you Pictures folder, so make sure you have them.
Finally let's get back to Window1.xaml and add a DataTemplate to display strings as Images.

PhotoAlbumCS.png

PhotoAlbumXaml.png

Now start the program and enjoy your Multitouch Photo Album :)

Last edited May 24, 2008 at 12:14 PM by nesher, version 8

Comments

DaksGreenday Mar 13, 2013 at 8:39 PM 
Hello, we got this tutorial working just fine and it looks great. My question is whether anyone has been able to add or change a photo after they are rendered? We are currently trying to make this possible but are having no luck due to binding issues. Any ideas?

jeffman1 Aug 24, 2011 at 3:53 PM 
question can this make the kinect act a multiple emulated mice because i want to test it with the quiz sample.

kasmatt Jul 2, 2009 at 1:50 PM 
This is owesome. Just tried it on windows 7RC. Just the one thing, how do I use the media element in the touchable panel. Every time I use it I get an error when running it. Any Ideas.

ShacharWeis May 21, 2009 at 7:02 AM 
Hello everyone,

I just managed to get the helloworld application running.
I see nice green dots where I touch, but the "Hello World" textbox is very sluggish and its
very hard to move it, it feels heavy and unresponsive.
I dont understand why, are there some parameters to change this behavior ?

Thanks,
Shachar Weis.

rad_thundercat Mar 23, 2009 at 6:17 PM 
I found the problem. "System.Collections.ObjectModel; and
System.IO; need to be added to the .cs.

rad_thundercat Mar 23, 2009 at 5:08 PM 
After following all of this I'm getting, "The type or namespace name 'ObservableCollection' could not be found (are you missing a using directive or an assembly reference?)" in the Window1.xaml.cs file

There is just one error, however, none of the "(ObservableCollection<string>)" lines are turning light-blue like in the screenshots above. I'm using Visual C# Express Edition -is this a limitation?

mr_empty Nov 20, 2008 at 8:02 PM 
Thanks for the tutorial, however I get "mt' is an undeclared namespace. Any ideas?

nickdb93 Jun 23, 2008 at 5:15 PM 
you guys should make videos to accompany these things, and post them on youtube. that would really help ppl, and drum up some mor interest in your project from other developers. i know it would help me.

nickdb93 Jun 23, 2008 at 4:58 PM 
wait.......what source code do i have to download to get Multitouch.Framework.WPF.dll ?