Small, self-contained projects that solve WinRT programming challenges
C# C Other
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
EnumerateFonts Enumerate Fonts in WinRT apps using SharpDX / DirectWrite to be able … Sep 13, 2012
GridViewAddNewItem Move other WinRT samples to Snippets repository Sep 13, 2012
HttpRequestViaSocketStream SocketStream sample (really, just a sample, do not use in production)… Sep 2, 2013
RenderTextToBitmap Move other WinRT samples to Snippets repository Sep 13, 2012
sqlite-winrt-samples SQLite samples (CRUD, querying, transactions, foreign keys, database … Apr 20, 2013
.gitignore Enumerate Fonts in WinRT apps using SharpDX / DirectWrite to be able … Sep 13, 2012
README.md Update README.md for new sample Sep 2, 2013
gridviewaddnewitem.png
listfonts.png Enumerate Fonts in WinRT apps using SharpDX / DirectWrite to be able … Sep 13, 2012

README.md

SQLite Samples

SQLite samples going beyond querying and CRUD:

  • Joins
  • Foreign keys
  • Transactions
  • Master database
  • Deployment of pre-created database to Windows 8 and Windows Phone 8

Enumerate Fonts in WinRT

This forum post hints that enumerating / listing fonts in C#/XAML WinRT apps cannot be done without DirectWrite. Having done dyamic image generation using SharpDX already, I searched the samples for font enumeration - and I found one that I converted into a Windows 8 app (I tested it with WACK).

This sample can be used as the basis for a font picker / chooser inside eg a flyout.

Screenshot

In Action

Render Text to Bitmap

WinRT's WriteableBitmap class isn't much of a help when you want to render a text into a bitmap in a Windows 8 App. Thus this sample uses SharpDX to create a bitmap and render it to a MemoryStream, which is then bound to an XAML Image control (using a neat random access memory stream as the basis for the BitmapImage).

The solution is based on ASP.NET code from a StackOverflow question (see link in the codebase). It tries to deviate as little from the original as possible.

Http Request via SocketStream

The code works on Windows Phone 8 and Windows 8 (uses identical WinRT API).

It shows how to use SocketStream to perform an HTTP GET request.

"Add New Item" item in GridView / ListView

In Action

This sample shows a WinRT app that uses the standard items template (GridView, with ListView for snapped view). It adds a "+" content item to the ItemsSource, which is used for the "Add New Item" action in the app.

Both the GridView and the ListView have been adapted via a DataTemplateSelector to look for the special item that is prepended to the list of actual items.

The code of interest is located in MainPage.xaml (Resources section and the controls) and MainPage.xaml.cs. AddNewItemTemplateSelector.cs hosts the datatemplate selector, AddNewItemItem.cs is used in the GridView more or less like a marker, in the ListView however we do show some info to help the user understand the item (adjust to your liking).