I have 2 models on my server side app ( TradeMarks & RetailStores ) each RetailStore have the TradeMarkId field for cross referencing. On my DomainService metadata model I defined the RetailStore(TradeMarkId field) as follows:
Class RetailStore:
[Display(Order = 5, Name = "RetailStoreTradeMarkTitle", Description = "RetailStoreTradeMarkDescription", ResourceType = typeof(RegistrationDataResources))]
public int TradeMarkId { get; set; }
On the client side I catch on the AutoGeneratingField the field and replace it by a combobox listing all the TradeMarks as follows:
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;
}
everything works perfectly in term of binding but I lost the "RetailStoreTradeMarkTitle", Description = "RetailStoreTradeMarkDescription" DisplayAttributes that I defined in the model! and I lost the Validation for this field.
So my question what am I doing wrong ? is there a way to get back the model validation & field headers ??
Thnaks in advance, WaMe