private void DetachButton(BindableApplicationBarButton button)
        {
            if (button.GetBindingExpression(DataContextProperty) == null &&
                button.GetValue(DataContextProperty) == this.DataContext)
            {
                button.DataContext = null;
            }

            button.Detach();
        }
        private void AttachButton(BindableApplicationBarButton button, int i)
        {
            if (button.GetBindingExpression(
                    FrameworkElement.DataContextProperty) == null &&
                button.GetValue(
                    FrameworkElement.DataContextProperty) == null)
            {
                button.DataContext = this.DataContext;
            }

            button.Attach(this.applicationBar, i);
        }