C#, UI, Windows 8, WinRT

Keyboard Dismissing ComboBox

In the last few days I came across a design issue with the touch keyboard on Windows 8. The keyboard dismissal logic (documented here) defines a list of controls which do not cause the keyboard to dismiss when they get focused. The purpose is to prevent the keyboard from opening and closing all the time when the user fills out a form and is likely to switch between keyboard-editable controls such as TextBox and other controls like AppBar, Checkbox, RadioButtons the ComboBox and some more. While that works fine with the other controls, ComboBox expands when interacted with and might get covered by the touch keyboard. And unfortunately you can’t change that behavior, or manually dismiss a deployed touch keyboard. (The user is in complete control over the keyboard.) While on the MSDN forums it was suggested to alter the layout such that the ComboBox is less likely to collide with the…

C#, Windows Phone

TCD.Web.NotiConn – communicate between handsets without a server

Two days ago, when I was cycling, suddenly I had the answer: Imagine you have two Windows Phone 7 devices and want to establish a two-way connection between them. For example to play a game of Tic-Tac-Toe. You can do this either with a server on the internet, that connects the clients with each other, or the multicast protocol on WiFi-networks. The same WiFi network may not always be available to both users, but you don’t want to set up a server either (maybe, because you’re only doing this for fun, or you don’t have the resources). The only way to send messages to a WP7 app via the internet is to use push notifications. But how do you exchange the channel addresses between the devices? One way is to use a QR code: Establish a push notification channel on both devices Encode the channel URI into a QR code…

C#, Kinect, Windows 8, WinRT


UPDATE: Source and samples for WinRT and WPF are now on GitHub: https://github.com/michaelosthege/TCD.Mathematics This is just a quick post to introduce you to TCD.Mathematics, which is a NuGet package that adds several extension methods to the System.Windows.Media.Media3D namespace. If you’re unfamiliar with this namespace, it contains Point3D, Vector3D, Line3D and Plane3D classes which can be used for three-dimensional calculations. EDIT: I just submitted an update to the NuGet package, wich adds support for WinRT. Please not that WinRT does not have neither Point3D, Vector3D, nor the System.Windows.Media.Media3D namespace. So in WinRT all classes, including substitutes for Point3D/Vector3D are located under TCD.Mathematics. EDIT: Since version 1.2.0 TCD.Mathematics is a Portable Class Library that targets everything: Silverlight 4+, .NET4+, .NET for Windows Store, Windows Phone 7+, Xbox360 – make sure you’re running version 2.1+ of NuGet Package Manager! The extension methods, which are added to the mentioned Point3D/Vector3D classes are: Vector3D.AsPoint3D() Point3D.AsVector3D() Vector3D.Normalized() Point3D.CenterOfClusterWithOtherPoint3Ds () Point3D.ProjectOnLine3D() Point3D…

C#, Kinect, UI, Windows 8


EDIT: If you’re interested in Skeleton tracking and calculating 3D stuff, take a look at TCD.Mathematics too^^ EDIT: There’s a WPF application that I once wrote, featuring SkeletonPainter3D: Kinect Sword. There’s a Youtube video of it (http://youtu.be/2j6GCd4M1bA) and that’s the source code: http://dl.dropbox.com/u/7813771/Blog/CodeSamples/KinectSword.zip   Hello there, I’ve created another UserControl, this time for Kinect and .NET 4.5, which hopefully has the potential to save you a lot of time. It can be used to draw three-dimensional Skeletons and explore the virtual space around them in real-time. A picture may be more appropriate: The control can be constructed in XAML: xmlns:kinect=”clr-namespace:TCD.Kinect.Controls;assembly=TCD.Kinect.Controls” <kinect:SkeletonPainter3D x:Name=”painter” Background=”Black” IsAnaglyphEnabled=”False” CameraFieldOfView=”70″ CameraPosition=”0,0.5,-1″ CameraLookAt=”0,0,2″ /> And populated with Skeletons using painter.Draw(skeletons), where skeletons is an Skeleton[] from inside the SkeletonFrameReady event. You can either get the TCD.Kinect package from NuGet, or refer to the sample implementation: http://code.msdn.microsoft.com/Implementation-of-f175b025 Let me know if you have any questions or suggestions, and by the way: SkeletonPainter3D has an experimental…

C#, UI, Windows 8

Windows 8 TouchInjection with C#

The Windows 8 platform provides an API to inject touch events (WM_TOUCH..) via a C++ API. The API is relatively easy to use, but not available in C#, unless you do DllImport/PInvoke. I found this to be kind of tricky, but finally I succeeded to make a C# library that can be used to use the TouchInjection API from C#. You can find TCD.System.TouchInjection on NuGet, or have a look at the TouchInjection.cs file itself. You may notice that I renamed all the strucs, enums and classes to look nicer than their C++ counterparts. The IntelliSense descriptions are available for almost everything! (I got them from the documentation on msdn..) I’ve made a sample application for the MSDN Code Gallery as well. Here’s a small collection of useful resources regarding the TouchInjection API: C++ sample application C++ TouchInjection API walkthrough

C#, Metro, UI, Windows 8, Windows Phone, WinRT


This is a summary and manual for all controls inside the TCD.Controls package. I’ll try to keep it updated. Windows 8 SilentTextBox – If AcceptsReturn=False and the user hits Enter normal TextBoxes make a ‘bling’ sound. SilentTextBox does not. HeaderedTextBox – A TextBox with a grey header above HeaderedTextBlock – A TextBlock with a grey header above; Automatically hides itself if the Text property is empty (unless AutoHide is set to False). LabeledProgressBar – a ProgressBar coupled with a TextBlock/Label; use it at the top of your page to indicate background progress (like the SystemTray.ProgressBar on Windows Phone) LayoutAwarePage – same as in all the samples Flyout – most recent post and how to use on Flyout SettingsContractWrapper – the easy way to integrate with the settings contract   Windows Phone CustomMessageBox – Async CustomMessageBox on Windows Phone ReverseAutocompletePopup – Making a reverse Autocomplete-TextBox on Windows Phone

C#, UI, Windows Phone, WinRT


Just another TCD namespace: TCD.Device. Its purpose is to contain additional namespaces that use features like Camera, GPS, Accelerometer, Compass.. Everything that has an effect on the App permissions the user sees on the Windows Phone or Windows 8 application. (Like ‘This app has access to your location, compass..’) TCD.Device.Camera CodeScannerPopup is another async control, specific to the Windows Phone platform, that can be used to scan for QR codes. (In theory other 2D-codes as well.) Usage: add the TCD.Device.Camera NuGet package add using directives for TCD.Device.Camera and TCD.Device.Camera.Barcodes in the calling method (eg. a Button.Click event) hide/show ApplicationBar, attach/remove BackKeyPress event Code sample: private async void Button_Click(object sender, RoutedEventArgs e) { CodeScannerPopup scp = new CodeScannerPopup(Microsoft.Phone.Shell.SystemTray.IsVisible, Format.ALL_1D); //important: hide ApplicationBar and handle BackKeyPress ApplicationBar.IsVisible = false; this.BackKeyPress += scp.HandleBackKeyPress; //now let’s go ScanResult r = await scp.ShowAsync(“BARCODE SCANNER”, “scan”); if (r != null) output.Text = string.Format(“{0}n{1}”, r.Text, r.Format.ToString()); //clean…

C#, Metro, UI, WinRT

TCD.Controls – Flyouts for XAML/C#

Hey there, Let’s start with the most important news: TCD.Controls is now available on NuGet (click here if you don’t know how this works, or why you want to use it) From now on, I won’t link *.zip packages with the sources anymore, because NuGet really make life easier. If you want access to the source files, just drop me an email There’s been one more or less important change to the Flyout control you should know about: It now has a property called “IsIgnoreLightDismissal”. To understand its purpose, imagine the following scenario (video below) You have a Button control that opens a FilePicker/FolderPicker, asking the user to select a File/Folder. This Button is hosted inside a Flyout control. Now when the user taps the Button, the Picker will popup, stealing the focus from your applications Window. Flyouts are required to hide on App-switch by the design guidelines, which is…

C#, WinRT

Exploring NuGet

Since 5 hours now, I ‘m on NuGet and I’d like to share my first experiences. Why did I join NuGet? I joined NuGet, because it seems to be the most comfortable way to share libraries, containing XAML controls. Share them between my own projects, as well as with you. Previously I always had to include the project containing the controls in the solution I was working on, which was really annoying.. How can you use it? Let’s assume that you want to use a package in your project. All you need is the NuGet Package Manager Visual Studio extension. You can install it via Tools/Extensions and Updates. To use/reference a package from NuGet right-click on the references in the solution explorer and select ‘Manage NuGet Packages’. Then you can search for the package you desire (for example ‘TCD.Serialization’) and add it to your project. How do I use it?…

C#, UI, Windows Phone

Async CustomMessageBox on Windows Phone

UPDATE: There’s a new Version with .NET4.5 Support, Code Samples Hey there, As you may know, there’s just a limited set of MessageBoxButtons available in Silverlight for WP. However, you can make your own MessageBox in your Silverlight app using the Microsoft.Xna.Framework.GamerServices namespace as explained in this tutorial by Den Delimarsky. This method uses the old style async, which really sucks, so I decided to go the cool and smart new async way. You need Visual Studio Async CTP and Visual Studio 2010 to do this. The trick is to wrap the old async methods together with async Tasks, resulting in a Task<int> that shows the custom message box and returns the selected button in just one line: int result = await CustomMessageBox.ShowAsync(“Dinner time!”, “What do you prefer?”, 0, CustomMessageBoxIcon.Alert, “German”, “Italian”); Asynchronously and therefore non-UI-thread-blocking, of course If you’re interested you can have a look at the source: CustomMessageBox.cs…