Since the ApplicationBar is not a DependencyObject and not part of the visual tree, FindElement cannot locate Items in the ApplicationBar with x:Name set.  The members will be null.


Due to this, it may be best to initialize the ApplicationBar using code behind and hold references to items which need to be dynamically changed.
( You could perhaps add these to a collection which was stored in App.Current.Resources. )


Notice in the code below that SaveEdit reference is held and SaveEdit.IsEnabled is updated with each keypress into the TextBox.


#region AppBar

private ApplicationBarIconButton SaveEdit;

private void InitAppBar()


ApplicationBar appBar = new ApplicationBar();

appBar = new ApplicationBar();


SaveEdit = new ApplicationBarIconButton(new Uri("images/", UriKind.Relative));

SaveEdit.Click += new EventHandler(OnClick_Check);

//SaveEdit.Text = Strings.Save_button;



ApplicationBarIconButton CancelEdit = new ApplicationBarIconButton(new Uri("images/", UriKind.Relative));

CancelEdit.Click += new EventHandler(OnClick_Cancel);

//CancelEdit.Text = Strings.Cancel_button;



ApplicationBar = appBar;


#endregion AppBar




void itemName_KeyDown(object sender, KeyEventArgs e)


bool isNameValid = itemName.Text.Length != 0;


if ((e.Key == Key.Enter) && isNameValid)





SaveEdit.IsEnabled = isNameValid;



Original article source:!AC1291870308F748!531.entry


Other Languages

This article is also available in the following languages:

Italian (it-IT)

Deutsch (de-DE)

Brazilian Portuguese (pt-BR)

See Also

Another important place to find a huge amount of Windows Phone related articles is the TechNet Wiki itself. The best entry point is Windows Phone Resources on the TechNet Wiki.