Binding to a LoopingSelector

Topics: Getting Started
Mar 14, 2012 at 11:32 PM

Hi,

This is my first project using Silverlight and I thought I'd try to 'do it properly' and use MVVM rather than code behind. But I'm struggling a bit.

I can link basic controls (like a text box) to my VM but I haven't been able to work out how to bind a LoopingSelector to the VM.

Simplified, my LoopingSelector is needed to display and allow selection of strings that are held in a class. At the moment they are in a List<> but I'm free to change this if required.

The LoopingControl will display the contents of the list if I specify this in the xaml but I can't work out how to obtain the selected item in the VM. Ideally I'd also like to specify the datasource in the VM.

 <toolkitPrimitives:LoopingSelector  ItemTemplate="{StaticResource NumberTemplate}"> 

<toolkitPrimitives:LoopingSelector.DataSource>                       

<Domain:NumbersDataSource Minimum="0" Maximum="9" />                   

</toolkitPrimitives:LoopingSelector.DataSource>               

</toolkitPrimitives:LoopingSelector>

Pointers in the right direction would be appreciated.