public void ShowAllRight()
 {
     DataTable dt = GetMenuTableByMenuRight();
     if (dt != null)
     {
         TreeItem tree = new TreeItem();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             if (dt.Rows[i]["SUB_FATHER_ID"].ToString() == "0")//加载第一级菜单
             {
                 TreeItem ti = new TreeItem();
                 ti.tag = dt.Rows[i]["SUB_ID"].ToString().Trim(); ;
                 ti.text = dt.Rows[i]["SUB_NAME"].ToString().Trim();
                 ti.parent = tree;
                 LoadTree(dt, ti);//递归函数
             }
         }
         tvPermissions.ItemsSource = tree.children;
     }
 }
        public void LoadTree(DataTable dt, TreeItem ti)
        {

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["SUB_FATHER_ID"].ToString().Trim() == ti.tag.ToString())
                {
                    TreeItem tiTmp = new TreeItem();
                    tiTmp.tag = dt.Rows[i]["SUB_ID"].ToString();
                    tiTmp.text = dt.Rows[i]["SUB_NAME"].ToString();
                    tiTmp.parent = ti;

                    LoadTree(dt, tiTmp);
                }
            }
        }
        /// <summary>
        /// 递归取消选中
        /// </summary>
        /// <param name="ti"></param>
        private void DiguiClearChecked(TreeItem ti)
        {
            if (ti.children.Count > 0)
            {
                foreach (TreeItem tii in ti.children)
                {
                    if (tii.IsChecked == true)
                    {
                        tii.IsChecked = false;
                    }

                    DiguiClearChecked(tii);
                }
            }
            else
            {
                if (ti.IsChecked == true)
                {
                    ti.IsChecked = false;
                }
            }
        }
        // 节点其他信息
        // ...

        public bool isTheChild(TreeItem p)
        {
            bool result = false;
            for (int i = 0; i < p.children.Count; i++)
            {
                if (p.children[i] == this)
                {
                    result = true;
                }
            }
            return result;
        }
        public void LoadTree(DataTable dt, TreeItem ti)
        {
            DataTable buttonTable = GetAllButton();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["SUB_FATHER_ID"].ToString().Trim() == ti.tag.ToString())
                {
                    TreeItem tiTmp = new TreeItem();
                    tiTmp.tag = dt.Rows[i]["SUB_ID"].ToString();
                    tiTmp.text = dt.Rows[i]["SUB_NAME"].ToString();
                    tiTmp.parent = ti;

                    //DataRow[] drs = buttonTable.Select("SUB_FATHER_ID='" + (tiTmp.tag as DataRow)["SUB_ID"].ToString() + "'");
                    //for (int j = 0; j < drs.Length; j++)
                    //{
                    //    TreeItem tiButton = new TreeItem();
                    //    tiButton.tag = drs[j];
                    //    tiButton.text = drs[j]["SUB_NAME"].ToString();
                    //    tiButton.parent = tiTmp;
                    //}
                }
            }
        }