我的服务器端应用程序(商标和零售商店)上有 2 个模型,每个零售商店都有用于交叉引用的 TradeMarkId 字段。在我的 DomainService 元数据模型中,我定义了 RetailStore(TradeMarkId 字段),如下所示:
Class RetailStore:
[Display(Order = 5, Name = "RetailStoreTradeMarkTitle", Description = "RetailStoreTradeMarkDescription", ResourceType = typeof(RegistrationDataResources))]
public int TradeMarkId { get; set; }
在客户端,我捕获了 AutoGeneratingField 字段并将其替换为列出所有商标的组合框,如下所示:
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!我失去了这个领域的验证。
所以我的问题是我做错了什么?有没有办法取回模型验证和字段标题?
提前感谢,WaMe