This question is locked. New answers and comments are not allowed.
I need to use a drop down combobox inside a DataForm, so that the user can select an item from it.
I use a ViewModel to get the details from the database as well as to save the users entered data.
Like this:
i inject the view model to page like this:
and my control looks like this:
Problem i am having is that once i have bound the DataForm to NewOrganisation, i can no longer bind the combobox to the VewTypes as they are not part of the NewOrganisation but rather on the same 'level' in me viewmodel.
How would you do this? What is the correct way of using DataForm in this case?
I use a ViewModel to get the details from the database as well as to save the users entered data.
Like this:
public NewClientViewModel() { if (!DesignerProperties.IsInDesignTool) { EntityQuery<VisibilityType> getVisibiltyTypesQuery = _context.GetVisibilityTypesQuery(); _visibilityTypes = new QueryableDomainServiceCollectionView<VisibilityType>(_context, getVisibiltyTypesQuery); _visibilityTypes.AutoLoad = true; } } public void LoadClients(int groupId) { _groupId = groupId; EntityQuery<Organisation> getOrganisationsByGroupIdQuery = _context.GetOrganisationsByGroupIdQuery(_groupId); _organisations = new QueryableDomainServiceCollectionView<Organisation>(_context, getOrganisationsByGroupIdQuery); _organisations.AutoLoad = true; _organisations.SubmittedChanges += new System.EventHandler<Telerik.Windows.Controls.DomainServices.DomainServiceSubmittedChangesEventArgs>(_organisations_SubmittedChanges); } private QueryableDomainServiceCollectionView<Organisation> _organisations; public IEnumerable Organisations { get { return _organisations; } } private QueryableDomainServiceCollectionView<VisibilityType> _visibilityTypes; public IEnumerable VisibilityTypes { get { return _visibilityTypes; } } private Organisation _newOrganisation; public Organisation NewOrganisation { get { return _newOrganisation; } set { if (value != _newOrganisation) { _newOrganisation = value; } } } i inject the view model to page like this:
public NewClient(int groupId) { InitializeComponent(); NewClientViewModel _viewModel = new NewClientViewModel(); _viewModel.LoadClients(groupId); this.DataContext = _viewModel; }and my control looks like this:
<telerik:RadDataForm Header="New Client" AutoGenerateFields="False" CurrentItem="{Binding NewOrganisation}" CommandButtonsVisibility="None" AutoEdit="True" AutoCommit="True" BorderThickness="0"> <telerik:RadDataForm.ReadOnlyTemplate> <DataTemplate> <StackPanel> </StackPanel> </DataTemplate> </telerik:RadDataForm.ReadOnlyTemplate> <telerik:RadDataForm.EditTemplate> <DataTemplate> <StackPanel> <telerik:DataFormDataField DataMemberBinding="{Binding Details.Name, Mode=TwoWay}" Label="Client Name:"/> <telerik:DataFormDataField DataMemberBinding="{Binding Details.Description, Mode=TwoWay}" Label="Description:"/> <telerik:DataFormDataField DataMemberBinding="{Binding WebSite, Mode=TwoWay}" Label="Web Site:"/> <telerik:DataFormDataField DataMemberBinding="{Binding Details.Notes, Mode=TwoWay}" Label="Notes:"/> <telerik:DataFormComboBoxField DataMemberBinding="{Binding VisibilityTypeId, Mode=TwoWay}" Label="Visibility:" DisplayMemberPath="Name" SelectedValuePath="Id" ItemsSource="{Binding VisibilityTypes}" /> </StackPanel> </DataTemplate> </telerik:RadDataForm.EditTemplate> </telerik:RadDataForm> Problem i am having is that once i have bound the DataForm to NewOrganisation, i can no longer bind the combobox to the VewTypes as they are not part of the NewOrganisation but rather on the same 'level' in me viewmodel.
How would you do this? What is the correct way of using DataForm in this case?