7/17/2008 10:42:00 PM
I'm working on a Silverlight 2 project currently and am running into sort of a wall when it comes to databinding. Without going into too much detail let's take into the consideration that I have the following objects.
List<Foo> list;
Repeater repeaterFoo;
My repeaterFoo's DataSource property is the list above. Let's say depending on a certain property of Foo that I want to display a 1 or a 2 in my UI. That's a pretty basic requirement right?
Here's how I would do this in ASP.NET:
<asp:Repeater ID="repeaterFoo" runat="server">
<ItemTemplate>
<%# string.IsNullOrEmpty(Eval("Name").ToString()) ? "1" : "2" %>
</ItemTemplate>
</asp:Repeater>
Now, for the sake of argument (and proof of concept); let's pretend that this example is 100% useful. How would I accomplish this in Silverlight 2 with it's funky { Binding PropertyName } syntax?
I'm not expecting any simple answer after seeing the dog-and-pony show that is formatting a date / currency in a Grid.
Don't get me wrong, I absolutely love Silverlight so far, it's just kind of frustrating trying to get used to the little things that were oh-so-easy in ASP.NET!
Thanks in advance.
UPDATE
I figured this out. New entry to come soon.
Hint: It relates to the dog-and-pony show I alluded to earlier :(
Silverlight

Comments

Just curious to know what you did to solve your problem.
Posted by: Ed | 11/18/2008 2:26:19 PM