Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1060
Button Command in Template Column
posted

Hello

Has anybody got an example of a XamGrid that successfully uses commanding on a button within the item template of a template column?

I have tried Prism commands and Silverlight ICommands with no luck.  The command fires OK in my viewmodel when I move the button outside of the XamGrid but not when it's in the column template. When i have done this before within in a listbox itemtemplate the addition of ElementName=LayoutRoot and adding DataContext to the binding path has worked but it doesn't seem to in this case.

Here's my XAML.

 

                <ig:TemplateColumn Key="AliasId"

                                   Width="Auto"

                                   HorizontalContentAlignment="Center"

                                   HeaderTextHorizontalAlignment="Center">

                    <ig:TemplateColumn.HeaderTemplate>

                        <DataTemplate>

                            <TextBlock Text="{Binding ItemAliasStrings.DeleteColumn, Source={StaticResource ItemAliasStrings}}"></TextBlock>

                        </DataTemplate>

                    </ig:TemplateColumn.HeaderTemplate>

                    <ig:TemplateColumn.ItemTemplate>

                        <DataTemplate>

                            <Button cal:Click.Command="{Binding DataContext.DeleteCommand, ElementName=LayoutRoot}"

                                    Content="{Binding ItemAliasStrings.DeleteColumn, Source={StaticResource ItemAliasStrings}}"

                                    Margin="5,0,5,0" />

                        </DataTemplate>

                    </ig:TemplateColumn.ItemTemplate>

 

                </ig:TemplateColumn>

 

 

Thanks

Kevin