Silverlight使用问题汇总一

  最近开始使用silverlight,使用中碰到很多问题,我打算将问题备案。

  使用框架:prism unity、Silverlight Ria.

  1.调试:Silverlight分客户端和服务器端,如果你想debug服务器端的代码,那么需要将服务器端项目设为启动项;如果要debug客户端,那么需要将客户端设为启动项。当然,你可以将两端项目都设为启动项,我试过,好像就第一次成了,后来都有些问题。

  

  2.启动项:如果你将SilverlightApplication1设为启动项,那么domain service即wcf是无法调用的,因为WCF并没有被host.当然,如果不使用domain service,直接使用WCF,并且host到IIS,估计可以访问,未测试过。因此,如果项目正式运行,应该将SilverlightApplication1.Web设为启动项,否则,会出现如下错误:

The provided URI scheme 'file' is invalid; expected 'http'.
Parameter name: via

  

  3.MVVM:获取不到对象的属性值

  使用MVVM模式时,实现下面以功能,在下面代码this.User.UserId处,死活得不到输入的值。最后在构造方法中实例化UserModel对象得到解决。

  

根据用户ID查询用户
   private void GetUser()
        {
            UserService us = new UserService();
            us.GetModel(this.User.UserId,(model) => {
                this.User= model;
            });
        }
构造方法
        public UserViewModel() 
        {
            this._User = new UserModel();
            this.GetUserCommand = new DelegateCommand(this.GetUser);
        }

 

 

 

posted on 2012-10-24 14:43  傍晚雨  阅读(391)  评论(0编辑  收藏  举报