private void ButtonsCollectionChanged(
object sender, NotifyCollectionChangedEventArgs e)
{
if (this.applicationBar == null)
{
return;
}
if (e.OldItems != null)
{
foreach (var oldItem in e.OldItems)
{
this.DetachButton((BindableApplicationBarButton)oldItem);
}
}
if (e.NewItems != null)
{
int i = 0;
foreach (var newItem in e.NewItems)
{
this.AttachButton(
(BindableApplicationBarButton)newItem,
e.NewStartingIndex + i++);
}
}
}
#endregion