Wednesday, March 21, 2012

Array Property

Is there a way to pass an array to a behavior via the declarative markup? I feel like I've come across a post on this before but can't find anything now. I'm looking for something like the following:

<my:ExtenderProperties Count="3" Values="one,two,three"/>

Is there a way to have this auto-fill a values[] or will I need to pass it in as a string and then split on a separator?

I haven't tried this, but have you considered making one of your properties (in the C# class) an Array type, then in the getter method for that you'd do something like return GetPropertyValue<Array>? Just a thought, as I said I haven't needed to try it myself yet.


Hi rchern13,

Does the following syntax look kind of like what you're talking about?

<my:Extender id="e" runat="server"
<my:ExtenderProperties TargetControlID="btn">
<Values>
<Value>one</Value>
<Value>two</Value>
<Value>three</Value>
</Value>
</my:ExtenderProperties>
</my:Extender>

I recently did something along these lines that you could look at in the Prototype project of the CodePlex version of the Toolkit (in the Components\Animation folder). [Warning: it's not very simple and requires a fair amount of code to do this...]

Thanks,
Ted


Warning: This will sound crazy.

I've written my own DropShadowExtender that allows a color to be passed in. I'm trying to turn it into a rainbow DropShadow so that I could say something like Count=3 Colors="Red,White,Blue" and voila it would create 3 shadowed divs.

Acutally, I got the array working, I used DropWatcherBehavior in the toolkit for an example. Now I just need to generalize the algorithmWink


Oh man, that was a heck of a lot easier than I expected it to be.

No comments:

Post a Comment