ComboBox for other than enum

7 posts, 1 answers
  1. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 17 Jul 2011 Link to this post

    I'm trying to load a collection (which is an attribute of an object) into a RadComboBox (instead of just having the id / ToString inside a textbox).

    I got this working so far with a datatemplate which I apply inside the AutoGeneratingPropertyDefinition Handler.

     

    DataTemplate dt = (DataTemplate)this.FindResource("TemplateComboBoxTemplate");                 
    e.PropertyDefinition.EditorTemplate = dt;

    The template looks like the following:
    <DataTemplate x:Key="TemplateComboBoxTemplate">     
        <
    telerik:RadComboBox ItemsSource="{Binding Source={StaticResource TemplateComboBoxSource}, Path=Templates}"
                            Margin="0">
            <telerik:RadComboBox.ItemTemplate>
                <DataTemplate>           
                    <TextBlock Text="{Binding Title}" />         
                </DataTemplate>       
            </telerik:RadComboBox.ItemTemplate>     
        </telerik:RadComboBox>   
    </DataTemplate>

    As I said, the above works great, except that I have no idea how to set up a two way binding
    so that the RadComboBox actually reflects the property.
  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Jul 2011 Link to this post

    Hi Roger,

    You may define the DataTemplate as follows:

    <DataTemplate x:Key="TemplateComboBoxTemplate">
                <telerik:RadComboBox ItemsSource="{Binding Clubs, Source={StaticResource MyViewModel}}"
                                     SelectedValue="{Binding ClubID}"
                                     SelectedValuePath="ID"
                                     DisplayMemberPath="Name"
                                     Margin="0">
                </telerik:RadComboBox>
            </DataTemplate>

    On other hand, you may create directly a LookupPropertyDefinition. I am sending you a sample project illustrating both approaches.
    Let me know in case you need any further assistance.
      Best wishes,
    Maya
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for WPF is Visual Studio 2017 Ready
  4. roger
    roger avatar
    24 posts
    Member since:
    Jun 2009

    Posted 18 Jul 2011 Link to this post

    Of course, thank you!
  5. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011

    Posted 12 Oct 2012 Link to this post

    Hi
    I hope it's not too late to get a reply to this thread.
    I'm getting to grips with the OpenAccess ORM, WPF Sofia Car Rental WCF Plain Services sample in OpenAccess 2012_2_816.
    I've built a solution based on this sample using my OpenAccess model.
    I've got a view with a RadPropertyGrid which displays an object successfully. I've also got an independent RadComboBox that displays a collection of reference data successfully. 
    One of the properties in the RadPropertyGrid is a reference id to an object in the collection displayed in the combobox.
    I've tried to use the LookupPropertyDefinition in the XAML, as shown in the sample you attached but I get binding errors which I'm unable to resolve.

    Is there a sample like the Sofia Car Rental sample that uses LookupPropertyDefinition?

    TIA 
    Craig
  6. Craig
    Craig avatar
    112 posts
    Member since:
    Nov 2011
  7. Dharmavaram
    Dharmavaram avatar
    72 posts
    Member since:
    Jun 2013

    Posted 29 Sep Link to this post

    Hi,

    I have similar requirement.could you please share the sample project in WPf.I am unable to open that silverlight Project and run.

     

    Regards,

    Nagasree.

  8. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 04 Oct Link to this post

    Hello Nagasree,

    On my end the sample application provided by my colleague runs as expected. However, I prepared the same demo in WPF for your convenience.

    I hope it helps.

    Regards,
    Stefan X1
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for WPF is Visual Studio 2017 Ready