With Microsoft Word being pretty much the ubiquitous document editor for students and teachers, I’m still puzzled to see just how poorly done references can be. What most people don’t realise is that Word isn’t just a basic document editor, but a fully featured academic toolkit. Through my entire university career, people were constantly blown away with how easy referencing can be with Word, compared to the hyperbolized “death trap of tricks” that our lecturers and tutors told us it would be.

If done correctly, references entered into word can follow you throughout your academic career, making every document just that little bit easier to write.

Let’s start off with filling out a new resource. In Word, the resources tab on the top menu will contain everything we need for the rest of the article.

After clicking “Manage Sources” a detailed popup will appear that looks similar to below. Except your left panel will be empty.


Click on “New…” to see the editor view.

The first Item we’re going to add is a book resource. Using the dropdown for “Type of Source”, make sure “Book” is selected. After completing the required fields (Show below) click “OK”. This item should now be added to your master list on the left, and the document list on the right.


We’re now going to add a URL based resource and have a look at the other optional fields. Click on the “New…” button again and select “Web site” from the dropdown.


The Goal with referencing in Word, is to throw it as much information as you can. To help with that, make sure you check “Show All Bibliography Fields” to see what you have to work with. The red asterisks indicate what you HAVE to include as a minimum.

Now, because there’s dozens of different painstaking ways you can write a reference, Word does all the heavy lifting again, giving you a list of options on how to render the information you’ve provided. If you’re not really sure what format to use, APA or Harvard is a solid bet.


Now that you’ve got all your resources added in, the next thing to deal with is inserting the Bibliography / Reference Widget into the page. Click the “Bibliography” button in the “References” menu to see a popup similar to below. Simply click the one you want and it will be inserted into the document at the current position.

If you’ve opted for a reference list, you now need to add in your citations. Again the “References” menu can help with an “Insert Citation” option. It automatically grabs the snippets from all your references and inserts the correctly formatted citation (for your given style) into the document.



The benefit to letting Word manage your resources, is that they’ll always be there and ready to use when you need them. It also takes all of the pain and stress about making the style and formatting changes for each item out of the equation, allowing you to focus 100% on your content!

How to stop sucking at academic referencing thanks to Word

Sometimes the hardest part of releasing software isn’t actually writing it, but how you deal with it once it’s released. If you’re a small start-up or have limited budget, advertising might not be a top priority (even sometimes with budget, it’s still not!).

The good thing is, just like all the major app stores, the Windows 8 store has built in review and rating functionality that helps users when making app decisions.

While that might not be the best thing depending on your user base, it is definitely something to consider.

Unlike Windows Phone, the Windows Store doesn’t have any inbuilt methods to help guide the user through a review / rating story. This is where the Review Helper comes in.

The Review Helper builds upon my previously mentioned SettingsManager, to store version numbers and run counts.

Using some basic logic it decided if the current version of the app has been executed x amount of times, and if so, prompts the user to review it. If the user accepts, the review panel from the store is loaded and ready for the user. If not, the user will not be reminded again until you release an update.

I’ve also included some tests in the below code, and built a test repository where you can see it work in a real App available here: https://github.com/LucasMoffitt/Windows-8-Review-Helper

Let me know what you think.

Windows 8 App Review Helper

Here’s a simple helper that might make some basic tasks easier in Windows 8.1 development. This is a generic wrapper around the Windows 8 / Windows 8.1 Roaming Settings methods. It’s great for basic types and is all but bulletproof when used correctly. It also just helps to clean up the code for setting and getting data. I’ve also included some basic tests that should help instill a little confidence.

I’m talking about it a bit here, but it will come in handy for future posts.


Basic Windows 8 Settings Wrapper

The vast majority of my Teacher Collection apps allow users to communicate with the web service in some way. This includes allowing teachers to do things like save their lesson plans to the cloud, backup classes and students, and manipulate their data from the web.

Before I can let someone in to play about with sensitive data, there has to be a level of authentication going on. While how that’s handled is another blog post, keeping the credentials safe on your device, and then getting the credentials to the API has been made thousands of times easier thanks to the Windows 8 PasswordVault.

The PasswordVault gives you access to the Windows 8 Credentials manager to well… manage credentials. In previous versions of windows, there wasn’t a simple way of managing in app credentials, in addition to dealing with securing the password, so this is a huge help.

I wanted to try and make it just a little bit easier to manage a set of credentials across apps, and hide the use of resource string, every time I need to get the value from the store.

Here’s what I’ve come up with, feedback is always appreciated!

Windows 8.1 C# PasswordVault Wrapper

For a recent side project, I wanted to be able to take some user given content, scour the web for it and see if it pops up anywhere else. It’s a pretty broad requirement and something I’ve thought about a lot off and on for the last few years. I looked into it a while back, when the Google API wasn’t so restrictive, but due to the complexity of what I wanted to do with the data, it quickly got thrown into the too hard basket.

Recently someone suggested that I checkout the Bing API to see what’s on offer. With 5,000 free requests a month it’s a decent start. While it may not be perfect for my use, it’s definitely worth checking out.

The Bing API allows you to return news results, web results images etc, it’s fairly comprehensive. For this demo I was only interested in the web results, which is great because Microsoft has provisioned its own plan for web results only. You can sign up for it yourself here: http://datamarket.azure.com/dataset/bing/searchweb If you find that 5,000 results are too little, you could probably mix and match API keys with the free 5,000 requests on the standard API here: http://datamarket.azure.com/dataset/bing/search

The Azure data market does provide some support for the Bing API, suggesting some basic examples, but they’re all pretty average in terms of readability and getting meaningful data back from a search result.

This demo takes your through building a decent Bing API hook in C#, so that you can easily query the Bing API and get data back in a useful format. If you’re interested in the end result checkout the code here: https://github.com/LucasMoffitt/Bing-Search also checkout the unit and integration tests if you decide to implement something similar in a production environment.

Starting with the domain

The Bing API Result returns a mess of Json, which is great for us because there’s already a stack of powerful Json tools that can handle Deserialization. Only problem being getting the data into the right shape for them to do the job. After inspecting the Json results from fiddler and looking at tools like http://json2csharp.com/ the C# domain looks a bit like this:

public class BingSearch
public List<Result> Results { get; set; }

public class Result
public Metadata __Metadata { get; set; }
public string ID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string DisplayUrl { get; set; }
public string Url { get; set; }

public class Metadata
public string Uri { get; set; }
public string Type { get; set; }

Creating the RestSharpClient

With our domain setup and ready to go, we need to start looking at how to make the request in C#, I prefer to use RestSharp for simple projects like this, but there’s no reason you couldn’t just use the HttpClient.

If you used the links above to create an account, you should now be the proud owner of a shiny API key. When connecting to the Bing Rest API with Basic Auth, simply provide the API key as the username and password. Using rest sharp it’s as easy as this:

private readonly RestClient _client;

public Searcher(string apiKey)
if (string.IsNullOrEmpty(apiKey))
throw new ArgumentNullException("apiKey");

_client = new RestClient();
_client.Authenticator = new HttpBasicAuthenticator(apiKey, apiKey);

The one thing that the RestSharp Json Deserializer isn’t good with, is dynamic objects. Because the Bing API returns Json wrapped in a “d” object and properties are lavishly prefixed with underscores and difference casing, we want a serious Json Deserializer to bash the results into our nice clean domain. Thankfully RestSharp lets us do this by plugging in our own handlers, in this case to deal with Json results.

public class DynamicJsonDeserializer : IDeserializer
public string RootElement { get; set; }
public string Namespace { get; set; }
public string DateFormat { get; set; }

public T Deserialize<T>(IRestResponse response)
return JsonConvert.DeserializeObject<dynamic>(response.Content);

and then adding it to the RestClient.

_client.AddHandler("application/json", new DynamicJsonDeserializer());

Building the request

So we have our nice and clean domain, we’ve got our rest client setup, now we need to build our request. The Bing API has a stack of different parameters you can apply, but for this example to show you the basic, we’re only going to worry about the actual search query and selecting the amount of results the API should return. Following the format below, it would be very easy to build upon that if required.

The API logic requires that if we make a response count request, that it be above 0. So easily enough we check if there’s an input number higher than 0, and if so we append the query. If not, we simply add the search query (called “Query”, which is mandatory).

The API also wants us to wrap the “Query” parameter with ‘ so we do that also. The request resource will change depending on if you’re using web results or the default API, in the web results only case, it should look like this: https://API.datamarket.azure.com/Bing/SearchWeb/v1/Web

Here’s my completed request logic.

public RestRequest BuildBingRequest(string query, int resultsCount)
var request = new RestRequest
Resource = "https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web",
Method = Method.GET,
RequestFormat = DataFormat.Json

if (resultsCount > 0)
request.AddParameter(new Parameter
Name = "$top",
Value = resultsCount,
Type = ParameterType.GetOrPost

request.AddParameter(new Parameter
Name = "Query",
Value = string.Format("'{0}'", query.Trim()),
Type = ParameterType.GetOrPost

return request;

Fire the laser

We’ve built our request. We’ve got our client and our shiny domain, now all we need to do is fire the request and get the data.

Using our Json.Net dynamic Deserializer we can easily bypass the pesky “d” wrapper and get straight to the search results.

public IEnumerable<BingSearch.Result> Search(string query, int resultsCount)
var request = BuildBingRequest(query, resultsCount);
var response = _client.Execute<dynamic>(request);
if (response.ResponseStatus == ResponseStatus.Error)
if (response.StatusCode == HttpStatusCode.Unauthorized)
throw new AuthenticationException("Api Key is not correct");

throw new Exception(string.Format("Request Error Message: {0}. Content: {1}.", response.ErrorMessage, response.Content));

return response.Data == null ? null : JsonConvert.DeserializeObject<BingSearch>(response.Data.d.ToString()).Results;

Now we’ve got something useful!

Bing Results Example

Bing Results Example

Just like any other collection of objects, you can now do whatever you want with the search results. In less than 100 lines of code, we can bend the Bing search platform to our will.

If you’ve got improvements to the demo code feel free to send a pull request, and same goes if you can think of more questionable areas that could use more testing.

tl:dr https://github.com/LucasMoffitt/bing-search

Getting meaningful data from the Bing API, using C#

Storing and Retrieving complex objects in Json using Windows 8.1 C#

Read below or skip right to the demo project, ignoring the terrible demo UI: https://github.com/LucasMoffitt/Save-and-Read-Json-Objects-Windows-8.1

So far, 90% of the Windows 8 apps I’ve written require storing data for later, or reading data that was stored earlier. There’s a million different ways to do it, but I’ve had great success with json.net and serialising / storing data this way. The only problem you have is when dealing with multiple types, and trying to figure out the best way to do it.

I’m not saying it’s the best way, but here’s what I’ve found that covers all of my requirements. I’ve condensed the class to make it easy for everyone to use, and you can even see it in action from the demo project.

This is the base abstract generic class called StorageBase, it will be responsible for all our heavy lifting.

What make this class awesome:

  • It deals with the get, getall, save and delete methods you’d expect with a storage system.
  • It requires the implementing class overrides the folder name property to split content into different folders of your Windows 8.1 app root.
  • It implements a constraint on the domain which looks like this…


The reason for that is due to how I name the files, no reason you couldn’t do it another way however.

Putting two and two together, this means that in order to manage multiple different object types as files, you can just create your domain model which inherits Identifiers, and a class which Inherits from StorageBase and call methods against it as per normal.

For example:

Hope this makes it easier to store complex objects in windows 8.1

Even if you’ve been living under a rock for a decade, you’d probably still know a little bit about the responsive web movement and the desire to make every app or site in the known world functional and visible on a screen the size of a watch. Why? Because reasons. That’s why.

The thing with being responsive is that there’s very few people who do it well (I am not one of them, although if you are looking for someone who is, checkout http://mattstow.com), and even if you decided you want to go down that path, it’s not always the easiest to learn.  This is further complicated in Windows 8.1 using XAML, as there’s not that many resources on how to achieve even some of the basics, as well as the traps that await young players.

For this demo, I’ve created a super basic Windows 8.1 C# / XAML app with a few different states. States are the changes in layouts we’ll apply when the app is at a specific screen size:


  • Default – What it looks like in full view
  • Smaller – If we collapse it down a little bit.
  • Even Smaller – again, just a little smaller
  • Snapped – 500px, (this is an option for one of the minimum widths in a Windows 8.1 app).


If you’d like to skip to the end, you can find the source code here: https://github.com/LucasMoffitt/ResponsiveXAMLDemo.

We’re going to start off with our default state. That is, best case scenario and what we’re aiming for. Below is the UI I’ve built for this demo, but you’d have any layout you want.

[note] I’ve included a little screen width counter in the bottom right hand corner to give us an idea of what we’re dealing with, and used it to decide where to place my UI breakpoints. [/note]


Responsive (ish) Xaml Demo

Now that we’ve got a basic layout (I’m using grids), we need to add in all our other states. At the moment unless you want to code it all by hand, Blend will be your best friend and sometimes your worst enemy.

Using blend, open up your current project and view, and head over to the States tab. Here’s where I spent a while pulling hair out… You need to create a VisualStateGroup and then add states to that, you don’t create multiple groups (unless you need to for some other reason).


After you’ve defined your states by name, and then you select one to work with, It automatically logs any changes you make VIA THE PROPERTY WINDOW!!! within that state. It should look like this.


I make the point of capitalising the “VIA THE PROPERTY WINDOW” because If you don’t use that to make the changes, it won’t make the change in the chosen state, but in the default state instead. Before you know it, your project is a bowl of spaghetti.

If you check your xaml after creating the states you should see similar to the following:


In the code of the current page, I plug in the following to manage the actual changing of states using my GetState method.

public MainPage()
SizeChanged += MainPage_SizeChanged;

private void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
VisualStateManager.GoToState(this, GetState(e.NewSize.Width), true);
ScreenWidth.Text = e.NewSize.Width.ToString();

Now here is where a designer would take everything into consideration and decide where the content should change for the best user experience. I’m not a designer, so I’ve just looked at the content and where stuff starts to collide, I’ve throw in a breakpoint.

Here’s my GetState method.

private string GetState(double width)
if (width <= 500)
return "Snapped";

if (width <= 660)
return "EvenSmaller";

if (width <= 755)
return "Smaller";

return "Default";

To summarise the logic I apply in these states:[list]

  • Below 755px, ditch the logo.
  • Below 660, change the title stackpanel from horizontal to vertical, increase some margins, make fonts smaller.
  • At Snapped, move Bill Murray into the right column row 0, content into row 1 and collapse column 0, make the fonts smaller again.


[note]In each state, if you’re working your way to a smaller view, you need to include the visual changes of the previous state. For example in <755px I hide the logo. That means I have to do the same in the <660px state [/note]


These are how mine look once I’ve changed the properties I’ve needed to in blend. 

Below 755

Below 755



Now like I said, this isn’t a visual design lesson, it’s not so much about the theory behind having Bill on top of the text, below it or wrapped around it, but the code you’d need to use to achieve something similar if handed a shiny mock up by a designer.

Here’s some examples from the code and where you’d use them. Some of these are generated by Blend, some are built through extensive searching and hair pulling.

Change the orientation of a stackpanel.



Move an item from one row or column to another.



Change a column or row definition (if you need to collapse or expand one).



A double animation can be used to change the font of an item, or just any other double based property such as height or width.



Change the visibility of a control



Change the margin of a control


Oh snap, Windows 8.1 XAML VisualStateManager cheat sheet.