Tips & Tricks for Playing Video with APL and Alexa

I am currently in the process of building an Alexa skill that contains all of the knowledge of the Star Wars Universe.  This includes characters, droids, weapons, vehicles, planets, creatures, and even different species and organizations.  It also includes the ability to request the opening crawl videos from each of the movies in the Star Wars saga, and the trailers for the movies, television shows, and video games.

It’s the videos that have brought me here to share what I have learned.

Alexa is available in a wide variety of devices.  Some small, some big, some with screens, others without.  For those devices with screens, I want to be able to provide my users with a simple workflow.

  1. Ask for a specific video.
  2. View the requested video.
  3. Continue the conversation when the video ends.

For the first two steps, this was surprisingly easy to implement using Alexa Presentation Language (APL.) . For the third step, it required some research and trial and error, but I have it working successfully now.

Identifying the Video a User Requested

While there is nothing complicated about identifying a user’s request, I’ll show you how I am handling this so that if you want to build your own version of this, you have everything you need.

In my Interaction Model, I have an intent called “CrawlIntent.”  This is there to handle all of the ways a user might ask to see the opening crawl of a specific film.  It looks like this:

  "name": "CrawlIntent",
  "slots": [
    "name": "media",
    "type": "Media"
  "samples": [
    "show me the {media} crawl",
    "{media} crawl",
    "can I see the {media} crawl",
    "show the crawl for {media}",
    "for the {media} crawl",
    "to show the crawl for {media}",
    "show me the {media} opening crawl",
    "{media} opening crawl",
    "can I see the {media} opening crawl",
    "show the opening crawl for {media}",
    "for the {media} opening crawl",
    "to show the opening crawl for {media}",
    "play the {media} opening crawl",
    "play the {media} crawl"

When a user says something to my skill like one of the utterances above, I can be confident they are looking for the opening crawl video for a specific film.  I also have a slot, called media that contains a list of all of the films and shows that I want my skill to be aware of.

  "values": [
    {"name": { "value": "Battlefront 2","synonyms": ["battlefront 2", "battlefront"]}},
    {"name": { "value": "Clone Wars","synonyms": ["the clone wars"]}},
    {"name": { "value": "Episode 1","synonyms": ["the phantom menace"]}},
    {"name": { "value": "Episode 2","synonyms": ["attack of the clones"]}},
    {"name": { "value": "Episode 3","synonyms": ["revenge of the sith"]}},
    {"name": { "value": "Episode 4","synonyms": ["a new hope", "new hope"]}},
    {"name": { "value": "Episode 5","synonyms": ["empire", "the empire strikes back", "empire strikes back"]}},
    {"name": { "value": "Episode 6","synonyms": ["return of the jedi", "jedi"]}},
    {"name": { "value": "Episode 7","synonyms": ["the force awakens", "force awakens"]}},
    {"name": { "value": "Episode 8","synonyms": ["the last jedi", "last jedi"]}},
    {"name": { "value": "Episode 9","synonyms": ["rise of skywalker", "the rise of skywalker"]}},
    {, "name": { "value": "Rebels","synonyms": ["star wars rebels"]}},
    {"name": { "value": "Resistance","synonyms": ["star wars resistance"]}},
    {"name": { "value": "Rogue One","synonyms": ["rogue one a star wars story"]}},
    {"name": { "value": "Solo","synonyms": ["han solo movie", "solo a star wars story"]}},
    {"name": { "value": "The Mandalorian","synonyms": ["the mandalorian"]}}
"name": "Media"
This slot allows me to match the user’s request against the list of items my skill can handle, using Entity Resolution.  This allows me to be certain that I’m choosing the right video for their request.


Playing A Video Using APL

For the code of my skill, I am using the Alexa Skill Kit SDK.  This makes parsing through the JSON that Alexa provides far easier, and gives me greater control over building responses for my users.

To add APL to my skill’s response, I do something like this:

var apl = require("apl/videoplayer.json");
apl.document.mainTemplate.items[0].items[0].source = media.fields.Crawl;
  type: 'Alexa.Presentation.APL.RenderDocument',
  token: '[SkillProvidedToken]',
  version: '1.0',
  document: apl.document,
  datasources: apl.datasources

Line #1 refers to the location of my APL document.  This document is the markup that tells the screen what to show.  Line #2 is dynamically updating the source of the video file to be played, so that we can play the appropriate video for the appropriate request.

As you’ll see in the APL document below, we define a Video element, and include a source property that indicates a specific URL for our video.

The important lesson I learned when building this is that I don’t want to include any speech or reprompts to my user in this response.  I can send this APL document to the user’s device, which immediately starts playing the video.  This is completely counter-intuitive to everything I’ve ever considered when building an Alexa skill, but it makes sense.  I’m sending them a video to watch…not trying to continue our conversation.

Adding an Event to the Video When It Is Finished

Finally, I had to do some exploration to figure out how to not only identify when the video has concluded, but also prompt my skill to speak to the user in order to continue the conversation.  This is done using the onEnd event on the Video element that we created earlier.  Here is the entire APL document.

  "document": {
    "type": "APL",
    "version": "1.1",
    "settings": {},
    "theme": "dark",
    "import": [],
    "resources": [],
    "styles": {},
    "onMount": [],
    "graphics": {},
    "commands": {},
    "layouts": {},
    "mainTemplate": {
      "parameters": [
      "items": [
        "type": "Container",
        "items": [
            "type": "Video",
            "width": "100%",
            "height": "100%",
            "autoplay": true,
            "source": "",
            "scale": "best-fit",
            "onEnd": [
              "type": "SendEvent",
              "arguments": [
              "components": [
          "height": "100%",
          "width": "100%"
    "datasources": {}
This is the second lesson that I learned when building this.  By adding this onEnd event, when the video finishes playing, it will send a new kind of request type to your skill: Alexa.Presentation.APL.UserEvent. You will need to handle this new event type, and prompt the user to say something in order to continue the conversation. I included the argument “VIDEOENDED” so that I’d be confident I was handling the appropriate UserEvent. Here is my example code for handling this:
const VideoEndedIntent = {
  canHandle(handlerInput) {
    return Alexa.getRequestType(handlerInput.requestEnvelope) === 'Alexa.Presentation.APL.UserEvent'
    && handlerInput.requestEnvelope.request.arguments[0] === 'VIDEOENDED';
  handle(handlerInput) {
    const actionQuery = "What would you like to know about next?";
    return handlerInput.responseBuilder
With these few additions to my Alexa skill, I was able to play videos for my users, but bring them back to the conversation once the video concludes.
Have you built anything using APL?  Have you published an Alexa skill?  I’d love to hear about it.  Share your creations in the comments!

Introducing the Smart Deck

We recently renovated our 15-year old wooden deck, and I wanted to share with you how we created a smart deck.  Here’s what it looked like before we started this project (we had already cut the benches up before I took the photo):


This video illustrates how it has changed pretty well.

The technology behind everything is actually pretty simple.  For the floodlight, it’s a standard floodlight hooked up to a WeMo Light Switch.  I’ve had this switch installed for about three years now, and it’s still the perfect solution.  We have 6 more of these throughout our house.

For the colored lights in the deck itself, I took a chance on a set of LED lights that I found on that were listed in the “Works with Alexa” category.  They’re made by a company called FVTLED.  Could not be happier with how they turned out.  Each 10-light kit costs about $100, but has a wi-fi module, a remote control, and an outdoor power supply as part of the kit.

You couldn’t see them in the dark (and I didn’t want to turn them on and wake the neighbors), but there are two speakers connected to a Bluetooth receiver mounted above the deck as well. This allows me to pair an Alexa device, or my phone, to the receiver, and play music through the speakers.

The Grace Digital receiver is small.  Maybe 6 inches wide, and 10 inches deep.

Grace Digital GDI-BTAR513 100 Watt Digital Integrated Stereo Amplifier with Built-In AptX Bluetooth Wireless Stereo Receiver

The Yamaha speakers are pretty standard outdoor speakers.  I had to run speaker wire to them, and they don’t require any additional power to run them.

Yamaha NS-AW150WH 2-Way Indoor/Outdoor Speakers (Pair, White)


Overall, I’m pretty happy with how this turned out.  I don’t actually expect that I’ll be running techno dance parties with flashing colored lights, but I love that I have the option.  Most of the time, I expect to be running standard white (or off white) colors.

Have you done anything cool to improve your outdoor living space?  I’d love to see it!

Circle Solves THAT Problem

Last week, I had several conversations with other parents at my son’s school about technology, smart home stuff, and our kids.  They were telling me about how they had a “Circle with Disney“, and how that made it so much easier to manage their kids’ time online.  Normally, in a conversation like this, I tend to be the one sharing the merits of some technology (software or hardware) that is somehow simplifying my life.  This time, however, I was on the other side of the conversation, and it was weird.

I’d never even heard of this device.  (What is a Circle with Disney?  I imagined it was a wi-fi router with Mickey’s ears that had simplified software for non-technical folks to understand.)  Even if I haven’t tried something, I’ve usually heard of it, or at least the category.  This one completely caught me off guard.  So I checked it out.

It. Is. Awesome.


It’s about the size of a can of soda, and it manages and reports all of the activity and devices that are on your wi-fi network.

You’ve probably seen clever images like this making the rounds on your social media:


The idea behind changing the wifi password every day seems brilliant.  “Kids, do your chores, and I’ll give you today’s password.”

In practical use, however, your kids aren’t the only ones using the wifi in your home.  Your phone, your laptop, your television, your Xbox, your light switches, your lightbulbs, your thermostat, your garage door, maybe even your refrigerator are using it too!  Nobody is going to change the wifi password on all of those devices every day, just to get their kids to do a few chores.

Circle solves that problem by giving you the ability to turn access to the Internet on and off for every single device (or person) on your network without any effort.  This means you can set specific limits for each person or device in your home.

Setting Up Your Circle

When you first set up your Circle, you go through a quick five minute setup, and then the work really begins.  You are presented with a list of every single device that is currently connected to your network.


I’d love to tell you that it automatically knows the name of every device on your network, and you won’t have to put on your Sherlock Holmes hat to figure some of them out, but I’d be lying to you.  I know my home is far beyond the average, but I have 44 devices on my network currently.  This includes:

  • 4 iPads
  • 3 iPhones
  • 3 computers
  • 2 light switches
  • 2 Amazon Dash buttons
  • 1 Garageio
  • 1 Fitbit Aria Scale
  • 6 Amazon Echo devices (Dot, Tap, Echo)
  • 1 Nest thermostat
  • 3 Rokus
  • 2 Xbox Ones
  • 1 Wii U
  • 2 webcams
  • 2 Apple TVs
  • 2 Nintendo DSs
  • 2 Amazon Kindles
  • 2 wi-fi printers
  • 2 televisions
  • 1 Logitech Harmony remote
  • a few wi-fi lightbulbs

Very few of them were obviously named, so I had to compare the MAC addresses to the Circle app to make sure I had the right one.  Even the iPads only identified as an iPad, so I had to make sure I knew which one was which.  Once you’re done with your sleuthing, however, it is magical, as you’ll see in the next section.  (My recommendation is to go to your router’s home page, and turn a device completely off.  If it disappears, that’s the one you were looking for.  Turn it back on, and mark it accordingly.)

What Circle Can Do

To start, you set up all of the people that live in your home.  For me, that’s my wife and my two children.


You’ll notice on most of the screens of the app, there’s a prominent PAUSE button available.  This turns off Internet access for all of the devices in context.  In the screenshot above, that would pretty much turn off everything that I’m managing with Circle.  (You can have a list of “unmanaged devices” as well, that aren’t affected by your actions in Circle.  This makes sense for things like your thermostat, which you’d never want to shut off unless your kids find a way to watch YouTube on it.)

You can also manage access on an individual level.


You can see above that I currently have five devices, and I don’t have many restrictions.  I’ll take you briefly through each of the sections.


Insights is for seeing data.  How much time a person was online, how much they used a certain app, etc.  Here’s a screenshot of my activity today:


I can open each of those sections and dive into websites visited, time spent at each, etc.  The downside to this, at least in my situation, is that if you have a browser tab open, it seems to count that as “activity.”  It’s especially prevalent when that tab auto-refreshes, because even background activity will be considered activity.  It is only monitoring the traffic from these devices, it isn’t checking to see what the traffic actually is.


The devices section just shows you all of the devices you’ve assigned to a specific person.  It’s entirely up to you how you assign devices, but my personal rule was to classify anything that has one unique user to a person, and things like the Xbox One, which many people use, to my Home group instead.


Opening a specific device gives you the MAC address, as well as a place to edit the Device name.  In most cases, the Manufacturer field will be filled in accurately, but not always.  I wish they would allow you to edit the Manufacturer field as well, but they don’t.  This is also where you can change where a device is assigned, or pause the access for this specific device.  (Circle manages your wi-fi access. It does offer an add-on program for $10/month that can also manage your cellular access.  I’m not using this, but I could see it being handy if you have a child that overuses data or spends time at school playing instead of learning.)


Filter Level

Filter level is simply some default settings for people of different ages.  When the Circle detects a user trying to access content that isn’t appropriate for their filter level, it will present them with a webpage that lets them know the content has been filtered.  It also restricts the apps/websites they can use, but you can customize all of it to fit your family’s needs.


Time Limits

As you’d imagine, Circle lets you set time limits for your users, and also by specific apps.  Many children need access to the Internet to do their homework, but they don’t need to be on YouTube while that’s happening.  This would allow you to limit their access to YouTube to 30 minutes a day, but their total time available could be more like three hours.



Bedtime is just another way to manage access times.  You can set a time that everything shuts off for a specific person, so then when they’re supposed to be in their room sleeping, they’re not sneaking in another four hours of Netflix.  Obviously, you can take the devices out of their rooms (as we do), but on the weekends, we tend to be a bit more lax.  This lets you be as lax as you want.



Overall, the Circle is an amazing device for my home.  Not only can I manage, view, and control what my children are accessing, but I also get this control for any additional devices that wander into my house, like the tablets and phones of their friends.  It gives me the peace of mind that they’re not going to venture to places I don’t want them going.  I don’t need angry neighbors asking why their child was watching something inappropriate at my house.

I get notifications every time a new device appears on my network, so there’s no way to sneak your way past the Circle, either.

Finally, I have to mention the Disney angle.  I mentioned that this device is called Circle with Disney.  It wasn’t obvious to me how Disney was even involved, other than the name.  They basically provide a portal on your network at  If you go to that page from any of your devices, it will tell you the specifics about the controls on that device (bedtimes, time limits), as well as a bunch of Pinterest-style photos and links to Disney content.  This seems to be the only real involvement by Disney, which is fine.


Lessons Learned In Using Microsoft Ads

Yesterday ended my first month of being an active Windows 8 app publisher.  The way I define “active” is that I have been consistently working to improve it since its launch.  There are many apps that are thrown into any marketplace, never to see an update of any kind.  In the first month, I shipped EIGHT updates.

Mind you, the first couple of updates were meant to solve two specific problems:

1)  Address a couple of small bugs I had identified.

2)  Get the Microsoft Advertising Control to actually work in my app.

Every app is going to have a bug or two, and there’s nothing terribly interesting about those, but the ads WERE tricky.  I created my ad units at PubCenter (which as it turns out, is not a place to find a frosty pint.)  I added an AdControl to the pages of my app using the identifiers from my ad units.  But they didn’t show up in my app when I published it.  In fact, after I published the first time, they didn’t show up in my development environment anymore either.

Being Lazy Was a Problem

One of the consistent pieces of feedback I had given developers was to uncheck the “Internet” option in the app capabilities if you weren’t using it.  Having that box checked also requires you to publish and include a privacy policy, and being lazy and averse to legalese, I decided my poker app, which didn’t have any need to connect to the internet, would not get this box checked.  (Of course, you do this right before you publish, not realizing you’re breaking everything.)

I opened a support ticket with PubCenter, and after a couple of days of trading emails and eliminating the obvious problems, they simply asked to see my code, if possible.  I pointed them to my github repository, where they identified that I had turned off “Internet” capabilities, and the AdControl needs this to serve ads.

Looking back, this is one of the most obvious statements I have ever written.

At the time, however, I seemed to me that the AdControl would probably have its own mechanisms for serving ads, and that they weren’t dependent on my app’s settings.  WRONG.

Anyways, once I flipped that switch on March 8th, the ads started showing up, and much to my surprise, I started making a little money.

Let’s Define “Making Money”

In the first few days after the ads started working, I averaged about $1.30 a day.  Not retirement money by any means, but my expectations were in the pennies a day range.  A dollar or more seemed HUGE.  Here’s a chart of my first month:


As you can see, March 18th was a huge day, grabbing me $4.55 that day.  I thought this thing was just going to take off.  As it turns out, that was my first day in the “New & Rising” category, and the shine slowly faded on that $4+ day.  Regardless, I’ve been consistently averaging more than $2 a day, which would be over $700 annually.  Not a fortune, but now I’ve got a baseline to start from, and I’ve got big plans to elevate that number over time.

What About eCPM?

The important number in the mobile app game is something called eCPM.  If you haven’t seen this term before, everyone uses is, but nobody really seems to define it.  eCPM means “effective cost per thousand impressions.” 

In simpler terms, this breaks down to the amount of money you made for every 1,000 times an ad was shown.  For the month of March 2013, my eCPM fluctuated as I was adding users, and ended up at an average of $0.73.  This number seemed a little low, until I looked at where I’m hovering each day lately:


Day to day, I’m averaging about $2.30 for my eCPM.  Since I’m averaging around 1,000 impressions per day, it makes sense that I’d be making about $2.00 a day.  (I’ve had peaks of 5,000+ impressions in a day, but lately it’s been more in-line with 1,000 per day.

So What’s Next?

My plans for the future are pretty simple: drive more impressions per day.  One idea I have for this is to offer a prize to users who hit a royal flush in the game.  This should incentivize people to play more, in the hopes they’ll win the prize.  I need to determine whether or not this is really legal, as well as whether or not it’s permitted in the Windows Store.

Another one is to make it more simple, and just reward those players that play more than a specific number of video poker hands each month.  Something like 10,000 hands.

In either case, I’m looking for ways to get more players to play more often, to drive up the number of impressions I’m getting each day, which should also drive up the amount of money I’m making each day.

I’ll keep you posted on how this all works out.

Lessons Learned From Rushing To Market


I’m still working on my Windows 8 application, King Poker, and have I learned some things this week.  (It’s also available for Windows Phone, btw.)

In general, my app is pretty straightforward.  It’s a video poker application designed to look as similar to the real video poker machines in casinos as it can.  Last week, I got ambitious, and decided to add some functionality that goes above and beyond the core functionality you’d expect.

I added Azure Mobile Services, and if the user was online, every single hand was recorded to my cloud storage database.  In the 10 days it’s been live, I’ve recorded over 45,000 random hands of video poker to my database.

In addition, I added Microsoft Account authentication, which means that if you log in with your Microsoft credentials, I could persist your credit count and hand history across all of your devices.  This is where the story gets ugly.

I spent HOURS writing and testing this functionality.  Log in on my Surface RT.  Play some hands of Deuces Wild.  Log out.  Keep playing.  Log in.  Play some more.  Cut the wi-fi connection.  Play some more.  Reconnect.  Sync the hands that were played when disconnected.  Log in to the Windows Phone 8 version.  See the identical credit count.  If you were logged in to these apps, everything worked marvelously.

When you weren’t logged in, it still worked marvelously.  It still logged your hands in my cloud database.  My mistake was that I didn’t notice that even when you were logged out, it was trying to sync your credits.  Anonymously.

So I pushed this new update chock full of new features to the store.  And it passed.  I was so excited!  And then the negative reviews started flowing in. 

“Used to work well on RT. Last update broke it. Lost all my money, well pretend money anyway. Please fix it”

“This is a great poker game. Play it all the time. However installed update yesterday and now it crashes all the time.”

“Credit counter still going crazy…Change the word HELD…back to HOLD, like in Vegas and Atlantic city…”

As it turns out, everyone that wasn’t logged in was synching their credits with everyone else that wasn’t logged in.  Ouch.

I’ve been really careful about thorough manual testing, as well as running a full suite of unit tests, but this one got by me.  I was so focused on what the experience was like for authenticated users, I didn’t give enough to time to think through all of the scenarios for those people that chose not to authenticate. 

I fixed it immediately, but it was Friday night, and the Windows Store team doesn’t approve apps on the weekends.  It wasn’t until Monday afternoon that my new patch was finally released, and almost immediately, I found yet another issue.  (It’s funny how much more obvious bugs are when they’re in production vs. development.)  I now have to wait at least another day before this issue will finally be solved.

Take Your Time

My point in all of this is to take your time.  I was so anxious to get my new set of features into the hands of my users, I completely neglected to remember that apps that have to go through stores are SIGNIFICANTLY harder to fix than a simple website.  If I find an issue on my website, I can fix it instantly.  In your app, your users may have to suffer through days or bugs before you’re able to fix an issue.  Take your time, get it right, and give your users the experience they deserve.  It’s the only way you’re going to get MORE users.

In short, no matter how great your set of features is, a little extra diligence to think through ALL of the user scenarios will benefit everyone in the long run.  That’s how you build a great app.  Keep your users’ confidence high, and give them a reason to tell their friends about it.

If you’d like to

Lessons Learned About Capturing Keystrokes in Windows 8

It would appear I’m going to start pumping out little “lessons learned” articles over the next few weeks, as I’ve learned an absolute TON from building my King Poker app.  Today’s lesson is about capturing keystrokes.

Many of you have probably done this before: you want to recognize a specific key that has been pressed when a user is entering something into a TextBox.  Maybe you want to take action when they press the Enter key, for example.  This is generally simple enough, you just set up a KeyDown (or KeyUp, depending on your needs) event on the TextBox in question, and then just check every time the event fires until you find the key you’re looking for.

That’s not what I wanted to do.

To give you some context, here’s a screenshot of my app:


For the cards in question, I want to hold the three Queens, and then re-deal, hoping to get the 4th Queen, or maybe one of the Wild Deuces.  (If I’m very lucky, BOTH!)

As the game currently stands, it is designed for use on a touch screen or with a mouse.  Clicking/tapping on a card will mark it as “HELD,” and won’t replace it when you click the “DEAL” button.  But you have to actually move your fingers or mouse to each card to mark them.  For speed players, they’d prefer physical buttons that can be pressed over having to touch a screen.

This is where my key capture needs come in.

I don’t have a control that I can just drop a KeyDown event on.  I want to be able to monitor keystrokes at all times.  For this, we can simply wire up an event in the code-behind file, and capture it there.  Here’s what it looks like:

protected override void OnNavigatedTo(NavigationEventArgs e)
    Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;

void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
    switch (args.VirtualKey)
        case Windows.System.VirtualKey.Number1:
            if (HoldRound) HoldCard(Card0);
            else SetBet(1);
        case Windows.System.VirtualKey.Number2:
        case Windows.System.VirtualKey.Number3:
        case Windows.System.VirtualKey.Number4:
        case Windows.System.VirtualKey.Number5:
            if (HoldRound) HoldCard(Card4);
            else SetBet(5);
        case Windows.System.VirtualKey.Space:

protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
    Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown;


As you can see above, I subscribe to the Window.Current.CoreWindow.KeyDown event, which fires before anything else gets access to the key event.  This is also a great way to capture keystrokes before they get to your TextBox controls, etc.

Once I’ve got this event rigged up (and un-rigged it with my OnNavigatingFrom event), I can now easily provide physical keys for my power users by enabling the #1 – #5 keys to hold the cards rather than having to move their mouse all over the screen.  In addition, I’ve also set the Spacebar up to provide “Deal” functionality, which means they never need the mouse once they start playing the game.  Here’s a look at the cards held:


And finally, in case you were wondering, here’s what I drew (I got that wild 2) to get my four of a kind!



So there you have it.  A simple way to capture keystrokes in C# and XAML applications for Windows 8/Windows RT applications.  Many apps have a need for this in some way (even if it’s to provide a shortcut or even an Easter Egg), so consider this in your applications as well.


What I Learned In WP7 – Issue 17

Man, things have been crazy.  I’ve got six apps in the marketplace right now, and going strong on about 7 more ideas.

I was asked today if there is an official “Download My App From the Marketplace” icon that we should use when linking to our applications from the web.  Turns out, there IS!  You can download the whole series here, but I’ve included a few examples below for you to check out.

wp7_278x92_red          wp7_278x92_green

wp7_278x92_blue          wp7_278x92_red

wp7_278x92_green          wp7_278x92_blue

What I Learned In WP7 – Issue 16

Yesterday, I had a developer reach out to me about a seemingly simple problem, but it wasn’t until I looked at it in a greenfield project that I could solve it quickly.  In the XAML below, I have a ListBox that I bind a List of objects to.  What the developer was trying to do was get the text in the “AlternateText” TextBox for the item clicked.

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
	<ListBox x:Name="masterList" SelectionChanged="masterList_SelectionChanged">
				<StackPanel Orientation="Horizontal">
					<Image x:Name="ActionImage" Source="{Binding ActionImage}" Width="100" Height="100"/>
						<TextBlock x:Name="ActionText" Text="{Binding ActionText}" FontSize="40" Width="300" />
						<TextBlock x:Name="AlternateText" Text="{Binding ActionDescription}" />

The important thing to remember here is that when you call the SelectionChanged event on a ListBox, the ListBox still recognizes each item as its original object.  Therefore, you should actually be trying to access the specific object that was selected, and then access the properties of that object, instead of the XAML elements that make up the ListBox’s layout.

Here’s the solution we implemented, where TestClass is the object type we’re using:

private void masterList_SelectionChanged(object sender, SelectionChangedEventArgs e)
	ListBox testList = sender as ListBox;
	TestClass testText = (TestClass)testList.SelectedItem;
	string whatImLookingFor = testText.AlternateText;

What I Learned In WP7 – Issue 15

I learned something about pricing your applications in the Windows Phone Marketplace  today that I never expected.  (Keep in mind this entire article is based on my sample size of ONE, but it’s an interesting thought exercise.)

Trial Mode might actually HURT your sales.

Let me explain:  I have been very diligent with my applications in the marketplace to make sure that they offer a compelling Trial mode to my users.  I want them to download it, and try it, so that they will ultimately buy it.  None of my applications are crazy addictive, or something that I thought would sell millions of copies.  Not by a long shot.  But I did think that I would sell SOME.

In fact, I am selling some.  Maybe 5 copies a day across all three of my paid applications (5 total, not 15).  Probably right in line with what I expected for the time/effort I put into some of these applications.  But I tried an experiment recently, and it had interesting results.

I am speaking at the CodeMash conference this week, and in one of my sessions, I am building a simple Twitter app alongside an iPhone developer and an Android developer.  We each get 15 minutes to build the same application.  (In other words, it’s incredibly simple.)

I decided it would be cool to have the application I was building for the session be available for download after the session, so I submitted it to the Marketplace over the holidays.  I had no trouble getting it submitted, but I decided to price it at 99 cents, with no trial mode (conversely, the rest of my applications offer limited functionality in Trial mode.)

Twitter Stalker (the app I’m talking about) sold 5 copies on New Year’s Day.  And has continued to sell at a higher rate than my other applications.  It’s description even says that “This is an application that was built as a demonstration at the CodeMash conference in Sandusky, OH on January 13, 2011.”


Now, I know that there are numerous factors that go into something like this, and one anomaly does not mean correlation.  For example, people might just be looking for a new Twitter client, and willing to spend the 99 cents to find out if it’s good.  On the other hand, if I had offered a trial mode, then they certainly would NOT have spent the 99 cents afterwards.  The app is really nothing special.

So, here’s your food for thought:

When building a simple application, is it more important for your users to LOVE your application?  Or is it more important to you that they BUY it?

I propose that if you’re building something simple, that can easily be explained in your description, perhaps a Trial mode isn’t something you should offer.  Perhaps people would be willing to pay 99 cents to find out if your application is what they’re looking for.  By offering a trial, you’re actually giving them the chance to NOT like it.

What do you think?

What I Learned In WP7 – Issue 14

I’ve been working on some dynamic Panorama designs, but there were a couple of things I was finding tricky:

1) Loading a Panorama control at a specific position. (also just navigating to a different place in one.)

2) Preventing a Panorama from wrapping around from the last to the first element.

In the first case, I just wasn’t looking in the right place.  To change which panel of a Panorama you are viewing, you can use:

Panorama.DefaultItem = Panorama.Items[index];

For the second case, you might be asking WHY I would want to prevent the Panorama from wrapping around, which is the default behavior.  In my application, when you first come to the Panorama control, you only have ONE PanoramaItem.  So scrolling is more confusing than anything else.  As you continue to enter data into the app, however, the Panorama can grow to as many as 10 Panorama items.

The short story on this, however, is that it’s not really possible.  If you need to change the Panorama’s behavior that drastically, you might want to look at using a different control.