Derik Whittaker

Syndication

News


Tip/Trick when working with the Application Bar in WinRT/Metro (C#)

When you are building out a WinRT/Metro application using C#/XAML you have the ability to add an ApplicationBar (part of the Windows.UI.Xaml.Controls namespace) to your application as seen below

image

When you adding a Application bar you can have it dock to the top or bottom.  When having it dock to the bottom you will want to make sure it is actually on the bottom.  For example, given the XAML below you may expect that the ApplicationBar would actually be at the bottom of the screen.

image

However, as you can see from the screen shot the blue bar is actually towards the top. 

image

The reason for this is because my page has a <Grid> in it with multiple rows and because I did not explicit set the grid the ApplicationBar should be placed in it defaulted to the first row (XAML Convention). 

From here I have 2 options

  1. Explicitly set the grid row my ApplicationBar should be assigned to
  2. Create a wrapper grid which contains your content grid along with any ApplicationBars

Personally I prefer option 2 because in my experience the number of rows will change over time and you may forget to update the Grid.Row setting in your ApplicationBar control.

Here is my final XAML in which I create the inner and outer <Grid> for my content and my app bars

image

And when I run the code above I get:

image

The moral of the post is this.  If your ApplicationBar is not in the location you would expect it make sure it is not placed inside a grid row or some other control which is changing its location.

Till next time,


Posted 10-30-2011 8:24 AM by Derik Whittaker
Filed under: , ,

[Advertisement]

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)