Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Use a Linq Query in Value Converter
1 replies. Latest Post by anyeone on December 23, 2008.
(0)
Congero8
Member
7 points
18 Posts
12-23-2008 2:46 PM |
I am trying to create a value converter that will convert an integer value in a ADO.Net Data Services Data Source to a text value that will be displayed in a Silverlight data grid. I'm able to retreive the correct value with my dataservices query but I don't know how to return the value to the grid. I am actually able to retreive the correct value in the Function LoadTransactionTypeCallback. How can I send this value back to the grid in my convert function?
Thanks
anyeone
Participant
811 points
182 Posts
12-23-2008 6:04 PM |
I haven't tried this but I suspect you will have a problem given the asynchronous nature of the service call and the synchronous nature of the IValueConverter.Convert method.
You may be better off not using the ValueConverter here and instead having your ADO.NET Services call retrieve both your integer value and the corresponding description at the same time, and use these to populate an object which can be set as a DataContext for your grid. Then you can use normal OneWay binding to a TextBlock or other control inside your grid, binding to the "Description" property on the object you defined.
Alternatively if you have only a fixed number of Transaction types, you may want to load the list of int/Description value pairs into a static resource as part of your initialization and use that as the source for a ValueConverter. I haven't done this myself, it is just an idea.
But, I suspect you will have problems trying to run a service call from inside a ValueConverter.