ItemsControl and TriggerAction or Command in Silverlight

ItemsControl and TriggerAction or Command in Silverlight

Old forum URL:

artsd posted on Wednesday, July 21, 2010

I am trying to bind an ItemsControl to a view-model. My view-model exposes a collection of objects which have a Name property. That Name property is used as the content of a HyperlinkButton. This part works fine. Now I am trying to use SL4 Command or CSLA TriggerAction to call a handler in the view-model. The problem is that inside the DataTemplate of the ItemsControl.ItemTemplate, any TriggerAction will be against the child of the bound collection instead of the view-model. I haven't figure out how to reference the datacontext of the ItemsControl which is the view-model.

<ItemsControl Grid.Column="1" Margin="5,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding Source={StaticResource UserMenuViewModel}, Path=PageLayout.Pages}" >

            <toolkit:WrapPanel Orientation="Horizontal" />

                <HyperlinkButton Margin="0,0,10,0" Content="{Binding Name}" />


Any ideas?

Copyright (c) Marimer LLC