2011-12-12 63 views
0

属性更改事件我发现Jaganathan Bantheswaran一个很好的职位在http://www.c-sharpcorner.com/uploadfile/dbd951/how-to-handle-property-changed-event-in-lightswitch-2011/使用其他实体

我理解这个概念,但我有使用其他实体应用它的麻烦。例如,将文凭百分比移到它自己的实体,将HS百分比移到它自己的实体。

我试过以下,但得到一个参数异常,无法找到控件DPercentage。

 void CreateNewStudent_PropertyChanged(object sender, PropertyChangedEventArgs e) 
    { 
     if (e.PropertyName.Equals("EntryMode")) 
     { 
      if (this.StudentProperty.EntryMode.Equals("LE")) 
      { 
       this.FindControl("DiplomaPercentage").IsVisible = true; 
       this.FindControl("HSSPercentage").IsVisible = false; 
       this.FindControl("DPercentage").IsVisible = false; 
      } 
      else 
      { 
       this.FindControl("DiplomaPercentage").IsVisible = false; 
       this.FindControl("HSSPercentage").IsVisible = true; 
      } 
     } 
    } 

student entity

student screen

回答

0

我假设这些行执行就好了:

this.FindControl("DiplomaPercentage").IsVisible = true; 
this.FindControl("HSSPercentage").IsVisible = false; 

然后抛出一个异常的:

this.FindControl("DPercentage").IsVisible = false; 

如果是这种情况,您是否检查过DPercentage确实是您的控件的名称?因为在屏幕上,DPercentage是显示名称。我无法验证控件名称是否也是DPercentage。

希望这会有所帮助。

相关问题