Archive for the Windows Phone Category

Scrollbar and Scrollviewer with Windows Phone

I just figured out a nice one concerning the interesting topic of the scrollbars with Windows Phone.

I had a hard time getting a scrollbar appear around my canvas. I then decided to change my code to replace the canvas with a grid, by replacing the SetValue (Canvas.TopProperty, y) and SetValue (Canvas.LeftProperty, x) with .Margin = new Thickness(x, y, 0, 0);

Still no result… In the end, after many tests,  I understood that somehow, the ScrollViewer computes the difference wetween its own height and its content height. And by setting its height to a smaller value than its content’s, it worked!

Like this:

<ScrollViewer Height=”800″ VerticalScrollBarVisibility=”Auto”>
<Grid x:Name=”MyGrid” Height=”1600″ />
</ScrollViewer>

And it worked!

My new Windows Phone app: Balloon Battle

It’s a game! I am happy to have it finally accepted in the market place! This app has been really fun to develop and to create, since it’s a game and it’s my first game. Here’s the link:

http://www.windowsphone.com/en-us/store/app/balloon-battle-free/034039f1-4981-40c2-b15e-a8796e8a0e40

While devleopping it, I really could get a deep understanding of Blend, storyboards, doubleanimations, rendertransforms and all these sweet little friends that you get to know in the wpf worls. I guess such an app is never really finished and can always be polished, but after 6 weeks work developing it (and I have a full time job, a wife and a kid), I feel quite exhausted and am just happy to relax a little.

So here it is! I hope you won’t find it too badly designed, feel free to express your remarks and please don’t be too harsh… :)

Forcing the update to Windows Phone 7.8 on my Lumia 800

Update 1: I just received the update from build 8779, not the expected 8858. At the end of that update, I was disappointed to see Zune tell me that my phone was up to date. Apparently, repeating exactly the steps described below, from step 1, is what needs to be done. Still no luck for me though… I guess it’s a matter of  timing? Anyway, good luck with your update!

Update 2: After multiple trials, I finally got it! Apparently (this kind of guess is always to consider very carefully), it seems that disabling the airplane mode on the phone between the 2 updates,  before reactivating it, AND THEN reproducing the steps below, is the way to do it.

 

There a few places on the web describing how to do this, here and here among others. None of them seems to be accurate enough if you ask me.

So here’s the exact process I followed to manage to get it to work on my phone (10 minutes ago):

  1. Make sure your phone is disconnected from your PC and Zune is shut down
  2. Put your phone in Airplane mode
  3. Connect it to your PC
  4. Zune starts automatically: wait a few seconds for the phone to be fully connected to Zune. You know that it’s the case when on the phone page, you see total space used.
  5. Go to Settings
  6. Attention, prepare yourself to click Update, and immediately after that, to disconnect your computer from the Internet
  7. A few seconds after doing that, Zune should inform you that an update is available for your phone: don’t do anything!
  8. Connect your PC back to the Internet
  9. Now click Update and let the magic begin…

After that, make sure to check the Places Manager App and let me know if you like it :)

 

New Windows Phone app: Places Manager

I just recently checked this small app and I must say it’s coming quite handy.

The app is called Places Manager, it’s free (comes with ads) allows mt to quickly save the places that matter to me, like home.

Than for each place, I can add tasks with reminders! Like in my case, I have added “Get out the trash” to Home. Until there, nothing really fancy, except for the fact that can quickly see the tasks that are related to a specific place.

And, for each place, you also get its direction (heading with a compass) and distance.

And, for each task, you can decide it to be “geo reminded”. That however, works only every 30 minutes. So if you drive through the supermarket and forget to stop, pity… But if you arrive at work and stay there all day, then you’ll get the reminder!

And you can choose if the “geo reminder” happens when arriving to some place, or when leaving a place.

And you can also create itineraries, ie circuits including multiple places. I must indeed use that when preparing a trek during the summer holidays, when I know I will have no Internet. At least, I will know offline: the distance to the next stage, and the direction to it!

Worth a look.

Windows Phone ads not showing up

Just check that you have the following capabilities mentioned in your manifest file: (see here)

WP7:

  • ID_CAP_IDENTITY_USER
  • ID_CAP_MEDIALIB
  • ID_CAP_NETWORKING
  • ID_CAP_PHONEDIALER
  • ID_CAP_WEBBROWSERCOMPONENT

WP8:

  • ID_CAP_IDENTITY_USER
  • ID_CAP_MEDIALIB_PHOTO
  • ID_CAP_NETWORKING
  • ID_CAP_PHONEDIALER
  • ID_CAP_WEBBROWSERCOMPONENT

Windows Phone Grid width: Auto or Star (*) ?

Here’s a typical XAML grid:

<Grid x:Name=”LayoutRoot” Background=”Transparent”>

<Grid.RowDefinitions>

<RowDefinition Height=”Auto”/>
<RowDefinition Height=”*”/>

</Grid.RowDefinitions>

<TextBlock Text=”Hello” />
<TextBlock Text=”Good bye” />

</Grid>

So what this means is :

  1. Auto means that the first row will automatically adapt to the size of its children or contained elements. So if it contains nothing, then the width will be zero.
  2. * means that the row will expand to use all remaining available space.

Long live Windows Phone!

Windows Phone: binding string concatenation

Imagine you have a textblock or button for which you want to display the object’s “name”. Let’s take a button:

<Button
Content=”{Binding Name}” x:Name=”Button”
Height=”70″ Click=”Button_click”
HorizontalAlignment=”Left”
/>

Now, you would like your button to not only display the bound object’s name, but to have precede it with “Name: “. No need to create a new get field in your class, you can use StringFormat like this:

<Button
Content=”{Binding Name, StringFormat=’Name: \{0\}’}” x:Name=”Button”
Height=”70″ Click=”Button_click”
HorizontalAlignment=”Left”
/>

Notice that everything after the equal sign is between single quotes, and that the curly brackets are escaped.

Windows Phone: background agent quick tip

Here a small thing that’s not necessarily obvious when playing with Windows Phone background agents:

  • Your background agent must reside in a new project!
  • You must add a reference, in your app project, to the background agent project
  • A possible way to share code between the app project and the background agent project is to use a third project
  • When accessing the same database both in the app and in the agent, Microsoft recommends using the Mutex concept to manage the concurrent access issues

Long live Windows Phone!

Windows Phone: cancel app submission

This seems like an obvious option for anyone reasonable out here. You spend countless hours designing and testing your app. The big moment finally comes, and you submit it. Then you play some more with your app, and notice a new horrible bug. Guess what, you can’t cancel your submission! It’s too late. You have to wait for the dreaded 3 to 5 business days to be totally elapsed, to be able to submit your app again.

Total non sense.

Please Microsoft, fix this.

Windows Phone: ready only database with indexes

When creating a Windows Phone app, you can use 2 different types of database: an empty database that offers read/write access to users, and a reference database already containing data, that offers read only access. Of course it is possible to copy a reference database in Isolated Storage to make it available in read/write access as well.

So, simple objective: make a database that contains data, available to users in readonly access. Easy enough right? Well, normally yes. The only thing to care about is the connection string.  The principle is as follows:

  • appdata is used for readonly databases
  • isostore is use for read/write access databases

BUT, if your database contains a lot of data, and that as a serious technical person you created appropriate indexes to your DB, then when trying to access it in readonly mode for the first time, your application might kindly produce this error message:

Access to the database file is not allowed

Because Windows Phone tries to recreate the indexes. Mmm, That deserves some head scratching. Finally, the only solution that I could come up with is:

  1. Load your database in isolated storage to allow read/write access
  2. Run your app, so that indexes get created
  3. Use the ISETool to extract your database out of Isolated Storage
  4. Make your database read-only

Mmm, that’s not exactly the smartest procedure ever, so please Microsoft, fix that.