This Forum is ARCHIVE only
For LightSwitch questions,
please use the official forums at:

http://social.msdn.microsoft.com/forums/en-US/lightswitch/threads


How To Bind To A Custom Control ComboBox
Last Post 17 Jun 2012 12:15 PM by admin. 17 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Michael WashingtonUser is Offline
Send Private Message
Posts:1313
Avatar

--
20 Jul 2011 09:56 PM






    < ComboBox Height = "23" HorizontalAlignment = "Left"
    Margin = "21,24,0,0" Name = "comboBox1"
    ItemsSource = "{Binding Screen.RIACommentsSet}"
    SelectedItem = "{Binding Screen.RIACommentsSet.SelectedItem}"
    DisplayMemberPath = "Comment"
    VerticalAlignment = "Top" Width = "120" />










    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    fishyUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:86
    Avatar

    --
    21 Jul 2011 03:26 AM
    Is there a way to make it more generic? Like have the Lightswitch app specifying the three binding elements to it?

    thanks
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    21 Jul 2011 04:02 AM
    Yes I cover that sort of binding in my E-Book
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    Holger FlickUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:7
    Avatar

    --
    02 Aug 2011 01:41 AM
    Great book btw... Would be great if you added a simple example how to add a custom control into a grid and how to databind it. I figured it out, but an example would be nice.
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    02 Aug 2011 01:52 AM
    Posted By Holger Flick on 02 Aug 2011 09:41 AM
    Great book btw... Would be great if you added a simple example how to add a custom control into a grid and how to databind it. I figured it out, but an example would be nice.


    It may be awile because I am so slammed right now, however, any normal Silverlight example you find will work. LightSwitch IS just Silverlight

    The only thing to remember is that with LightSwitch your data context is "Screen".

    I do regret that I did not cover datagrids in the book. I will move datagrids up my priority list.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    TerryHUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:4
    Avatar

    --
    02 Sep 2011 12:01 AM
    Michael

    First off, this site is very helpful with lots of very useful information, keep up the good work!

    The blog about MVVM made me realize that I could be able to replace most of the generic LS screen with a custom control, I could use Blend to create the replacement screen. But I have ran into a problem with comboboxes. I can't get them to work. I can get the combobox to display a list, but I can't seem to get it to update the main record. I have an Individual record that has a relation to City. here is the XAML

    VerticalContentAlignment="Center" IsEditable="True"
    ItemsSource="{Binding Screen.Cities}"
    SelectedValue="{Binding Screen.Individual.CityId, Mode=TwoWay }"
    DisplayMemberPath="Name"
    SelectedValuePath="CityID" />

    Could you make a suggestion ?
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    02 Sep 2011 12:07 AM
    Darn I havn't had a chance to do that yet and I wont be at a LightSwitch computer until tomorrow. My guess is that:
    1) SelectedValuePath="CityID" is not the same case as "Binding Screen.Individual.CityId"
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    xristUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:1
    Avatar

    --
    05 Sep 2011 09:54 PM
    Hello Michael,

    In your book you show how to bind a slider using code from lightswitch(Method One: Directly Binding A Silverlight Control).You use the slider from system.windows.control library.I understand that, i do something similar with a combo box from the same library and it works.The problem is that this method doesn't seem to work when i create a combo box in a silverlight class.I add the reference, i select the combo box, i write the same code but it doesn't seem to be binding to anything.Only the windows combo box binds, not mine.

    So except from binding it hard coded in the Xaml file, binding from lightswitch doesn't work.Am I missing something?(Note: I have followed every tutorial and method that i could find)

    Thank you.
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    05 Sep 2011 10:05 PM

    So except from binding it hard coded in the Xaml file, binding from lightswitch doesn't work.Am I missing something?(Note: I have followed every tutorial and method that i could find)

    Thank you.

    I am not sure I understand your question. The example in this forum post shows the binding of a Silverlight Control ComboBox.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    omarUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:1
    Avatar

    --
    14 Sep 2011 03:46 AM
    Hi! Michael I have a question.

    I created a custom control for DataGrid I used the ReadGridView of Telerik, I have a DataContext Screen.ClientArticles in this Screen I have a collection of clients and I want to Binding a GridViewComboBoxColumn. Have you an idea how can I do it?

    My code is the next:

    DisplayMemberPath="{Binding Path=Name}" SelectedValueMemberPath="{Binding Path=Id}" />


    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    14 Sep 2011 04:10 AM
    Sorry I don't have any examples.
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    USMAN CHOHANUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:15
    Avatar

    --
    26 Sep 2011 12:34 AM
    Hi, Can you please tell me how can I bind a Combo box from code behind...???

    In your Example above, you have bind the control to the screen (Which is also from the same table)

    >>

    What If I have to bind the combobox from another table, which has no relation with current Screen...???
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    26 Sep 2011 01:26 AM
    Posted By USMAN CHOHAN on 26 Sep 2011 08:34 AM
    Hi, Can you please tell me how can I bind a Combo box from code behind...???

    In your Example above, you have bind the control to the screen (Which is also from the same table)

    >>

    What If I have to bind the combobox from another table, which has no relation with current Screen...???

    PLace the collection on the screen (in the left hand side of the screen designer)
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    USMAN CHOHANUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:15
    Avatar

    --
    26 Sep 2011 05:06 PM
    Posted By Michael Washington on 26 Sep 2011 09:26 AM
    Posted By USMAN CHOHAN on 26 Sep 2011 08:34 AM
    Hi, Can you please tell me how can I bind a Combo box from code behind...???

    In your Example above, you have bind the control to the screen (Which is also from the same table)

    >>

    What If I have to bind the combobox from another table, which has no relation with current Screen...???

    PLace the collection on the screen (in the left hand side of the screen designer)

    Hi,

    Can you please Explain what I have to do...???
    what do u mean by collection???

    I am trying something like this...
    "ItemsSource="{Binding Screen.Tasks.TaskType}" SelectedItem="{Binding Screen.Tasks.TaskType.SelectedItem}" DisplayMemberPath="{Binding Screen.Tasks.TaskType.TaskType1}"

    But it didn't work... 

    Can you please Explain, what I have to do for this...

    Thanx...!!!



    USMAN CHOHANUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:15
    Avatar

    --
    26 Sep 2011 07:35 PM

    How to change in the .Xaml code. so it will return the Id from the

    database for the selected item from Combobox...
    USMAN CHOHANUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:15
    Avatar

    --
    26 Sep 2011 10:01 PM
    Thanx... I have found it my self...
    AkamaUser is Offline
    New Member
    New Member
    Send Private Message
    Posts:3
    Avatar

    --
    17 Jun 2012 10:28 AM
    Hi Michael,

    Great job you are doing. Thanks a million.

    Can you point me to which ebook you refered to above? and where to purchase it.
    Michael WashingtonUser is Offline
    Send Private Message
    Posts:1313
    Avatar

    --
    17 Jun 2012 12:15 PM
    -----------
    Michael Washington
    http://LightSwitchHelpWebsite.com
    You are not authorized to post a reply.


    Microsoft Visual Studio is a registered trademark of Microsoft Corporation / LightSwitch is a registered trademark of Microsoft Corporation