public TreeViewItem GenerateTreeViewItem(TopMenus topMenusModel)
        {
            var treeViewItem = new TreeViewItem
            {
                Header      = topMenusModel.DisplayName,
                DataContext = topMenusModel
            };

            treeViewItem.Selected += TvLeftTopMenusItem_Selected;

            return(treeViewItem);
        }
        private void AddTreeViewItem(TreeView treeView, ItemCollection items, TreeViewItem selectedItem, TopMenus topMenus)
        {
            if (topMenus.ParentId == 0)
            {
                treeView.Items.Add(GenerateTreeViewItem(selectedItem));
                selectedItem.IsSelected = true;
                return;
            }

            foreach (var i in items)
            {
                var item = (TreeViewItem)i;
                if (((TopMenus)item.DataContext).Id == topMenus.ParentId)
                {
                    item.Items.Add(GenerateTreeViewItem(selectedItem));
                    selectedItem.IsSelected = true;
                    item.IsExpanded         = true;

                    var requestModel = new TopMenusUpdateSortRequestModel
                    {
                        DisplayName = topMenus.DisplayName,
                        Sort        = int.MaxValue,
                        Timestamp   = _topMenusManage.ServerTime.ToUnixTimestamp()
                    };
                    var result = _topMenusManage.UpdateSort(topMenus.Id, Timestamp, requestModel);
                    if (result.ResultStatus == ResultStatus.Success)
                    {
                        topMenus.DisplayName = result.Data.DisplayName;
                        topMenus.Sort        = result.Data.Sort;
                        topMenus.Timestamp   = result.Data.Timestamp;
                    }
                    else
                    {
                        _metroWindow.ShowMessageAsync("更新节点排序失败", result.Message);
                    }
                    break;
                }

                if (item.HasItems)
                {
                    AddTreeViewItem(treeView, item.Items, selectedItem, topMenus);
                }
            }
        }