Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Binding a Combobox in a user control
3 replies. Latest Post by Savij on November 1, 2009.
(0)
Savij
Member
1 points
7 Posts
10-29-2009 10:54 PM |
Hello,
I am trying to create a user control that contains a combobox and 2 textblocks. I want to expose binding points in xaml so I can bind the text properties on the textblocks and also bind the combo box. Again I want to do all of my binding in xaml rather than in code.
I am only working on the combobox binding right now, once I get that working, the text properties should be easy enough.
Here is what I am thinking (but it's not working):
My user control xaml looks like this:<sydControls:CascadingPicker TitleText="Select Year" FooterText="Hover To Change" Margin="8,241,513,94" ComboDataContext="{Binding Source={StaticResource YearDataSource}}" ComboItemsSource="{Binding Mode=OneWay}" ComboItemTemplate="{StaticResource YearsComboItem}" />
Everything builds fine, but running the page gives me:""AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 180 Position: 131]"
Which points to "ComboDataContext" .... I am baffled on this one. Can anyone point me in the right direction?
Thanks!
-Savij
RogerGu
Participant
870 points
255 Posts
10-29-2009 11:32 PM |
I would first try to make the error go away before you make it funciton properly. If you you remove the ComboDataContext, does it run without error? And it seems you have the two reversed. Wouldn't you give the ComboItemSource the YearDataSource?
Twitter
10-30-2009 9:01 AM |
If I remove the properties that set the bindings, then yes it compiles and runs, but of course, the combo is empty. So that doesnt really get me anywhere. As far as the two being reversed, I copied the 3 properties (DataContext, ItemsSource and ItemTemplate) from a working combobox on the same page, then I just added the word "Combo" in front of the 3 property names and made sure they matched properties on the code behind. The original post is the result.
I played with the code last night for a while longer, but I am unable to get it to populate the combobox.
11-01-2009 9:04 PM |
I found my answer and wrote a blog article about it. With how common this would be in a production application and the fact that I was not able to get much help on the subject, I wonder how many people are just playing with the technology and how many really use Silverlight for production applications?? I think it will get better over time (use and support).
Anyway, here is the article, hope it helps someone out there. Let me know with a comment on the blog if you find it useful (or if anything is incorrect of course).
Savij.com
Enjoy!
-Savijwww.savij.com