silverlight怎么实现控件绑定数据库中数据

silverlight如何实现<controls:TreeViewItem>控件绑定数据库中数据
silverlight如何实现<controls:TreeViewItem>控件绑定数据库中数据?急求代码 ***是现成的demo 数据库***是sql



------解决方案--------------------
其实网络上已经有了很多楼主需求的实例,Silverlight绑定Treeview分为两部分,
1. 客户端部分,treeview绑定
2. 数据库交互部分,负责SQL数据读取;

第一部分,你可以参考一下几篇教程,其中有 源代码下载:
http://www.silverlightchina.net/html/tips/2010/0510/1110.html

http://www.silverlightchina.net/html/tips/2010/0101/515.html

http://www.silverlightchina.net/html/tips/2010/0101/514.html

http://www.silverlightchina.net/html/tips/2010/0101/513.html

http://www.silverlightchina.net/html/tips/2009/1211/391.html

http://www.silverlightchina.net/html/developer/2009/1212/393.html

第二部分,你可以参考下面的教程,WCF与SQL的通讯,其中也有源代码查看:
图文详解Silverlight访问MSSQL数据库

http://silverlightchina.net/html/tips/2009/1229/503.html

http://silverlightchina.net/html/zhuantixilie/getstart/2009/1210/387.html
------解决方案--------------------
C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

using System.ServiceModel.DomainServices.Client;
using ABISCustom.Web;

namespace ABISAdmin
{
    public partial class temp : Page
    {
        DomainServiceCustom customContext = new DomainServiceCustom();

        public t_sys_Group modelGroupCw = new t_sys_Group();
        public List<t_sys_Group> listGroup = new List<t_sys_Group>();
        public List<t_sys_Menu> listMenu = new List<t_sys_Menu>();
        //public List<v_GroupMenuList> listVGM = new List<v_GroupMenuList>();
        
        
        public temp()
        {
            InitializeComponent();

            showTree();

        }

        // 当用户导航到此页面时执行。
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

            

        }


        void showTree()
        {
            //清除树的所有节点
            tvMenu.Items.Clear();
            listMenu.Clear();
            tvMenu.DataContext = null;

            var query = (from menu in customContext.GetT_sys_MenuQuery()
                         select menu);
            LoadOperation<t_sys_Menu> contact = customContext.Load(query);
            contact.Completed += new EventHandler(contact_Completed);

        }

        void contact_Completed(object sender, EventArgs e)
        {
            LoadOperation<t_sys_Menu> contact = (LoadOperation<t_sys_Menu>)sender;

            listMenu = (from menu in contact.Entities
                       select menu).AsQueryable().ToList();

            AddTreeNode("ZZZZ", null);

            //指定选择项开始=========================================
            TreeViewItem tr = new TreeViewItem();
            tr = tvMenu.Items[0] as TreeViewItem;
            tr.IsSelected = true;
            //指定选择项结束=========================================

        }

        private void AddTreeNode(string parentID, TreeViewItem treeViewItemTemp)
        {

            List<t_sys_Menu> result = (from menuInfo in listMenu
                                            where menuInfo.PMenuCode == parentID
                                       select menuInfo).ToList<t_sys_Menu>();

            if (result.Count > 0)
            {

                foreach (t_sys_Menu menuinfo in result)
                {
                    TreeViewItem objTreeNode = new TreeViewItem();
                    objTreeNode.Header = menuinfo.MenuName;

                    objTreeNode.DataContext = menuinfo;
                    objTreeNode.IsExpanded = true;

                    if (treeViewItemTemp == null)
                    {
                        tvMenu.Items.Add(objTreeNode);

                    }
                    else
                    {
                        treeViewItemTemp.Items.Add(objTreeNode);
                    }

                    AddTreeNode(menuinfo.MenuCode, objTreeNode);
                }

            }
        }

    }
}