This is a migrated thread and some comments may be shown as answers.

Issues with DataFormComboBoxField binding

2 Answers 57 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 Mar 2019, 10:45 AM

Hi guys,

I am having some issues with binding the DataFormComboBoxField.  I am setting the item source of the comboboxfield to a collection that is not stored in the CurrentItem of the RadDataForm.  I wish to update the EditableModel with the JobID from the selected drop down value.  Also the Combobox should have the item selected base on the item set in the EditableModel on load.  Any help would be appreciated.  

 

VIEW MODEL

    public class EditableViewModel : ReactiveObject
    {
        public EditableModel SelectedEntity { get; set; }
        public List<JobModel> Collection { get; set; }
    }

 

Models

    public class EditableModel
    {

        public string Name { get; set; }
        public int JobId { get; set; }
    }

    public class JobModel
    {
        public string Name { get; set; }
        public int Id { get; set; }
    }

VIEW

<reactiveui:ReactiveWindow 
    x:Class="TestWpfApplication.MainWindow"
    x:TypeArguments="test:EditableViewModel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:test="clr-namespace:TestWpfApplication.ViewModels"
    xmlns:reactiveui="http://reactiveui.net"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    Title="NuGet Browser" Height="450" Width="800"
    mc:Ignorable="d">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="MyTemplate">
                <StackPanel>
                    <telerik:DataFormDataField  Label="First Name" DataMemberBinding="{Binding Path=Name, Mode=TwoWay}"  />
                    <telerik:DataFormComboBoxField  Label="Job" SelectedValuePath="Id" DisplayMemberPath="Name" DataMemberBinding="{Binding JobId, Mode=TwoWay}" ItemsSource="{Binding Jobs, Mode=TwoWay}"/>
                </StackPanel>
            </DataTemplate>
        </Grid.Resources>
        <telerik:RadDataForm AutoGenerateFields="False" x:Name="RadDataForm" EditTemplate="{StaticResource MyTemplate}"/>
    </Grid>
</reactiveui:ReactiveWindow>

 

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 14 Mar 2019, 02:19 PM
Sorry the collection properties should be Jobs
0
Vladimir Stoyanov
Telerik team
answered on 19 Mar 2019, 09:34 AM
Hello David,

Thank you for the provided code snippet. 

May I kindly ask you to elaborate a bit on the described scenario? Can you share what is the ItemsSource/CurrentItem of the RadDataForm set to? Additionally, can you elaborate a bit on the need for the different classes JobModel and EditableModel? If there isn't a need for both of them, perhaps you can simplify the data representation and use only one class. 

If possible, you can prepare a small sample project demonstrating your scenario and send it over in a new support ticket. This will hopefully allow us to check out the scenario and better assist you.

Thank you in advance for any help you can provide. 

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DataForm
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or