56 Generate O2m Form (Country) (Wpf) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
For the Country we have Dialect which is a detail entity.
O2m-form (one-to-many form) is a master-detail.
- To generate O2m-form for Country View
- Right Click
- Literature/LitCountry of "ModelServicesPrismModule"-project
- And select “Wpf Forms Wizard” menu item to open the Wizard dialog
- Right Click
- Note:
- On the first page of the dialog the destination folder is shown. The destination folder is the folder in which the generated file will be saved.
- Click “Next”-button
- On the second page of the dialog the developer should select existing DbContext file. Select:
- Dm02Context (project)
- LitDbContext (context)
- Click “Next”-button
- On the third page of the dialog the developer should select the View. Select:
- “LitCountryView“.
- Click "Next"-button
- On the fourth page of the dialog the developer should click "Batch Processing"-button
“Batch actions” dialog will be shown. - Select “01700-O2m.json” - Click “Start”-button
LitCountryViewO2mUserControl
-component will be generated
- Under ModelServicesPrismModule-project
- open the file "Literature/LitCountry/ViewModels/LitCountryViewO2mViewModel.cs" and follow the instruction at the beginning of the file
/*
"LitCountryViewO2mUserControl" UserControl is defined in the "ModelServicesPrismModule"-project.
In the file of IModule-class of "ModelServicesPrismModule"-project the following line of code must be inserted:
public void RegisterTypes(IContainerRegistry containerRegistry)
{
...
// According to requirements of the "LitCountryViewO2mViewModel.cs"-file of "ModelServicesPrismModule"-project.
ViewModelLocationProvider.Register<LitCountryViewO2mUserControl, LitCountryViewO2mViewModel>();
// According to requirements of the "LitCountryViewO2mViewModel.cs"-file of "ModelServicesPrismModule"-project.
containerRegistry.Register<UserControl, LitCountryViewO2mUserControl>("LitCountryViewO2mUserControl");
// According to requirements of the "LitCountryViewO2mViewModel.cs"-file of "ModelServicesPrismModule"-project.
containerRegistry.RegisterForNavigation<LitCountryViewO2mUserControl, LitCountryViewO2mViewModel>("LitCountryViewO2mUserControl");
...
}
*/
- Open "ViewModels\MainWindowViewModel.cs"-file of the PrismDemoApp-project
- Modify _MainMenu variable as shown
IEnumerable<IWebServiceFilterMenuInterface> _MainMenu = new ObservableCollection<IWebServiceFilterMenuInterface>()
{
new WebServiceFilterMenuViewModel() { Id = "000", Caption="Home", IconName="Home", IconColor="Primary", Data="HomeUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="LitGenre Lform", IconName="TableRefresh", IconColor="Primary", Data="LitGenreViewLformUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="LitEdition Lform", IconName="TableRefresh", IconColor="Primary", Data="LitEditionViewLformUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="Country Lform", IconName="TableRefresh", IconColor="Primary", Data="LitCountryViewLformUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="Language Lform", IconName="TableRefresh", IconColor="Primary", Data="LitLanguageViewLformUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="Dialect Lform", IconName="TableRefresh", IconColor="Primary", Data="LitDialectViewLformUserControl", Command=RoutedCommandExt.MainMenuCommand},
new WebServiceFilterMenuViewModel() { Id = "001", Caption="Country O2m form", IconName="TableRefresh", IconColor="Primary", Data="LitCountryViewO2mUserControl", Command=RoutedCommandExt.MainMenuCommand},
};
- rebuild
- ModelInterfacesClassLibrary
- ModelServicesPrismModule
- PrismDemoApp
- run Dm04WebApp
- run PrismDemoApp
- In the app click "Country O2m form"-menu item and add a pair of records to the dialect-panel