/// <summary>
        /// Initializes the comments tab
        /// </summary>
        private void InitializeComments()
        {
            //get up to date comments for the current map

            BindingWrapper <ContentItem> wrapper = (BindingWrapper <ContentItem>)DataContext;

            CommentsListBox.Visibility = Visibility.Collapsed;

            ArcGISOnlineEnvironment.ArcGISOnline.Content.GetComments(wrapper.Content.Id, (object sender2, CommentEventArgs e2) =>
            {
                if (e2.Error != null || e2.Comments == null || e2.Comments.Length == 0)
                {
                    return;
                }

                //sort comments by date since chronological order is not guaranteed by agol response
                //newer comments come first in the list
                //
                List <Comment> sortedComments = new List <Comment>(e2.Comments);
                sortedComments.Sort(CompareCommentsByDate);

                ObservableCollection <BindingWrapper <Comment> > wrappers = new ObservableCollection <BindingWrapper <Comment> >();
                foreach (Comment comment in sortedComments)
                {
                    BindingWrapper <Comment> commentWrapper = new BindingWrapper <Comment>();
                    commentWrapper.Content = comment;

                    User user          = ArcGISOnlineEnvironment.ArcGISOnline.User.Current;
                    commentWrapper.Tag = Visibility.Collapsed;
                    wrappers.Add(commentWrapper);
                }
                CommentsListBox.ItemsSource = wrappers;
                CommentsListBox.Visibility  = Visibility.Visible;
            });
        }
        /// <summary>
        /// Occurs when the hyperlink button to show the map description in a separate browser tab has been clicked.
        /// </summary>
        private void OpenDescriptionInBrowserButton_Click(object sender, RoutedEventArgs e)
        {
            BindingWrapper <ContentItem> wrapper = (BindingWrapper <ContentItem>)DataContext;
            string url = ArcGISOnlineEnvironment.ArcGISOnline.Content.GetItemUrl(wrapper.Content.Id);

            Util.Navigate(url, "_blank");
        }
        /// <summary>
        /// Occurs when the Open button is clicked.
        /// </summary>
        private void OpenButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            BindingWrapper <ContentItem> wrapper = (BindingWrapper <ContentItem>)DataContext;

            RaiseMapSelectedForOpening(this, new ContentItemEventArgs()
            {
                Item = wrapper.Content
            });
        }
        private void populateGroups(ObservableCollection <BindingWrapper <Group> > wrappers, Group[] groups)
        {
            if (groups != null && groups.Length > 0)
            {
                foreach (Group group in groups)
                {
                    BindingWrapper <Group> wrapper = new BindingWrapper <Group>();
                    wrapper.Content = group;
                    wrapper.Tag     = IsUserOwnerOfGroup(group) ? Visibility.Visible : Visibility.Collapsed;

                    wrappers.Add(wrapper);
                }

                MyGroupsListBox.ItemsSource = wrappers;
                MyGroupsListBox.Visibility  = Visibility.Visible;
                SearchResultsTextBlock.Text = string.Format(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyGroupControlGroups, groups.Length);
            }
            else
            {
                SearchResultsTextBlock.Text = ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.MyGroupControlZeroGroups;
            }
        }
        /// <summary>
        /// Raised when the tab of the MapDetailsTabControl changes.
        /// </summary>
        private void MapDetailsTabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (MapDetailsTabControl == null)
            {
                return;
            }

            switch (MapDetailsTabControl.SelectedIndex)
            {
            case 0:     //properties
                break;

            case 1:     //decription

                FailedDescriptionPanel.Visibility = Visibility.Collapsed;

                if (_richTextLoaded)
                {
                    BindingWrapper <ContentItem> wrapper = (BindingWrapper <ContentItem>)DataContext;
                    try
                    {
                        DescriptionRichTextBlock.Html = wrapper.Content.Description ?? "";
                    }
                    catch
                    {
                        // formatting to html has failed - show the message and hyperlink
                        FailedDescriptionPanel.Visibility = Visibility.Visible;
                    }
                }
                break;

            case 2:     //comments

                InitializeComments();
                break;
            }
        }