Issues with DataFormComboBoxField binding

3 posts, 0 answers
  1. David
    David avatar
    2 posts
    Member since:
    Mar 2019

    Posted 14 Mar Link to this post

    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. David
    David avatar
    2 posts
    Member since:
    Mar 2019

    Posted 14 Mar in reply to David Link to this post

    Sorry the collection properties should be Jobs
  3. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    476 posts

    Posted 19 Mar Link to this post

    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.
Back to Top