/// <summary>
        /// Builds the tree for MenuItem tree view model
        /// </summary>
        /// <param name="node"></param>
        /// <param name="menuItemViewModel"></param>
        void BuildTreeViewModel(ISyntaxEntity node, MenuItemViewModel menuItemViewModel)
        {
            MenuItemViewModel item = new MenuItemViewModel()
            {
                DisplayText = node.DisplayText(),
                SpokenText  = node.SpokenText(),
                Name        = node.DisplayText(),
                LineNumber  = node.Location.StartLineNumber + Constants.GoToLineOffsite,
                Children    = new ObservableCollection <MenuItemViewModel>(),
                IsExpanded  = (node is Block || node is FunctionDefinition)?false:true,
                ImageSource = UIConstants.GetImageSourceFromKind(node)
            };

            if (null == menuItemViewModel)
            {
                treeRootViewModel = item;
            }
            else
            {
                menuItemViewModel.Children.Add(item);
            }

            menuItemViewModel = item;

            if (null == node.Children)
            {
                return;
            }

            foreach (var child in node.Children)
            {
                if (child.Kind == SyntaxEntityKind.Function)
                {
                    if (((child as FunctionDefinition).TypeOfFunction & functionTypesToDisplay) == 0)
                    {
                        continue;
                    }
                }
                BuildTreeViewModel(child, menuItemViewModel);
            }
        }
        public void SetListView(IEnumerable <ISyntaxEntity> entities, string label, bool focusOnFirst = true)
        {
            //Cleaning UI
            listView.Visibility = Visibility.Visible;
            treeView.Visibility = Visibility.Collapsed;
            ListItems.Clear();

            var listItems = entities.Select(entity =>
            {
                return(new MenuItemViewModel()
                {
                    DisplayText = entity.DisplayText(),
                    SpokenText = entity.SpokenText(),
                    Name = entity.DisplayText(),
                    LineNumber = entity.Location.StartLineNumber + Constants.GoToLineOffsite,
                    Children = new ObservableCollection <MenuItemViewModel>(),
                    ImageSource = UIConstants.GetImageSourceFromKind(entity)
                });
                //return new MenuItem(entity.CurrentCodeFile.Language.SpokenText(entity),
                //                                            entity.Location.StartLineNumber);
            });

            foreach (var item in listItems)
            {
                ListItems.Add(item);
            }

            listView.Focus();

            /// Focus explanation:
            /// The ListViewItems are not generated immediately, because of that we can obtain the ListViewItem to shift focus.
            /// Hence we call ListView.UpdateLayout() which pre-generates the ListViewItems.
            /// Since there are only few tens of items expected in the list view, this is acceptable.
            /// In case the list items will go to hundreds or thousands, this is not efficient way, we need to use the
            /// status chaged event of the ItemContainerGenerator to get the ListViewItem.
            if (true == focusOnFirst)
            {
                listView.SelectedItem = listView.Items[0];
                listView.UpdateLayout();
                var item = (ListViewItem)listView.ItemContainerGenerator.ContainerFromItem(listView.Items[0]);
                if (null != item)
                {
                    item.Focus();
                }
            }
            else
            {
                listView.SelectedItem  = listView.Items[listItems.Count() - 1];
                listView.SelectedIndex = listItems.Count() - 1;
                listView.UpdateLayout();
                var item = (ListViewItem)listView.ItemContainerGenerator.ContainerFromItem(listView.Items[listItems.Count() - 1]);
                if (null != item)
                {
                    item.Focus();
                }
            }


            isTreeViewActive = false;

            ResizeControl();
        }