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}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<HyperlinkButton Margin="0,0,10,0" Content="{Binding Name}"
/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Any ideas?
Copyright (c) Marimer LLC