2011-12-14 2 views
0

내 서버 측 앱 (TradeMarks & RetailStores)에 2 개의 모델이 있습니다. 각 RetailStore에는 상호 참조를위한 TradeMarkId 필드가 있습니다. 다음과 같이 내가 AutoGeneratingField에 필드를 잡아 모든 상표를 나열하는 콤보 상자에 의해 대체 클라이언트 측에Silverlight 4 - DataForm (AutoGeneratingField)의 RIA 서비스 DataField 헤더

Class RetailStore: 
[Display(Order = 5, Name = "RetailStoreTradeMarkTitle", Description = "RetailStoreTradeMarkDescription", ResourceType = typeof(RegistrationDataResources))] 
public int TradeMarkId { get; set; } 

:

다음과 같이 내 DomainService 메타 데이터 모델에 은 내가 RetailStore (TradeMarkId 필드) 정의
 if (e.PropertyName == "TradeMarkId") 
     { 

      ComboBox TradeMarkIdComboBox = new ComboBox { DisplayMemberPath = "TradeMarkName" }; 
      Binding itemsSource = new Binding("TradeMarks") { Source = this.retailStoreDomainDataSource.DomainContext }; 
      Binding selectedItem = new Binding("TradeMark") { Mode = BindingMode.TwoWay }; 
      TradeMarkIdComboBox.SetBinding(ComboBox.ItemsSourceProperty, itemsSource); 
      TradeMarkIdComboBox.SetBinding(ComboBox.SelectedItemProperty, selectedItem); 

      DataField TradeMarkIdField = new DataField 
      { 
       Content = TradeMarkIdComboBox, 
       Label = e.Field.Label 

      }; 
      e.Field = TradeMarkIdField; 

     } 

바인딩은 모두 완벽하게 작동하지만 모델에서 정의한 "RetailStoreTradeMarkTitle"Description = "RetailStoreTradeMarkDescription"DisplayAttributes를 잃어 버렸습니다! 이 필드에 대한 유효성 검사를 잃었습니다.

내 질문에 내가 뭘 잘못하고 있니? 모델 확인 & 필드 헤더를 가져 오는 방법이 있습니까 ?? 사전에

Thnaks, WaMe

답변

0

나는이 꽤 새로운 해요,하지만 난 문제가 e.Field 비트 생각 - 당신은 아마 e.Field.ReplaceTextBox를 사용한다.

난 그냥 아주 비슷한 구현이 코드는 나를 위해 일한 : -

 if (e.PropertyName == "TradeMarkId") 
     { 
      ComboBox target = new ComboBox() { DisplayMemberPath = "TradeMarkName", SelectedValuePath = "TradeMarkId" }; 
      target.ItemsSource = TaskManager.Manager.GanttItemSource; 
      e.Field.ReplaceTextBox(target, ComboBox.SelectedValueProperty, binding => binding.Converter = new TargetNullValueConverter());    
     } 

는 당신을 위해 일하는 희망! ID 속성을 선택해야한다는 것을 염두에 두십시오. 상표 ID로 사용하는 필드가 확실하지 않습니다. "TradeMarkId"라고 추측했습니다.

관련 문제