This is a migrated thread and some comments may be shown as answers.

Can´t binding a command inside Cell Template

1 Answer 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 20 Oct 2011, 10:46 AM
Hi there,

In my gridView I have a custom column and inside I have a HyperLink button with a command that have a binding for my viewModel.
However I can´t binding the button inside the cell Template.

Please look at my xaml.

<Grid Grid.Row="1" Margin="0">
                <telerik:RadTabControl>
                    <telerik:RadTabItem>
                        <telerik:RadTabItem.Header>
                            <TextBlock Text="Assuntos da Reunião" Width="210" Cursor="Hand" HorizontalAlignment="Center"></TextBlock>
                            
                        </telerik:RadTabItem.Header>
                        <telerik:RadTabItem.Content>
                            <Grid x:Name="gridAssuntos" Width="700" Height="560" Margin="4,41" VerticalAlignment="Top" HorizontalAlignment="Center">
                                <telerik:RadGridView x:Name="grdMensagens" ItemsSource="{Binding Path=DataContext.OCAssuntosReuniao,ElementName=LayoutRoot}"
                                    BorderThickness="0" HorizontalAlignment="Center" Width="Auto" Height="Auto" Grid.ColumnSpan="3" RowHeight="15"
                                    AutoGenerateColumns="False"  IsReadOnly="True" VerticalAlignment="Top"
                                    ShowGroupPanel="False" ShowColumnFooters="False" RowIndicatorVisibility="Collapsed" LoadingRowDetails="grdMensagens_LoadingRowDetails"
                                    Cursor="Hand">
                                    <swi:Interaction.Triggers>
                                        <swi:EventTrigger EventName="Loaded">
                                            <esi:CallDataMethod Method="grdAssuntos_Loaded"/>
                                        </swi:EventTrigger>
                                    </swi:Interaction.Triggers>
                                    <telerik:RadGridView.Columns>
                                        
                                        <telerik:GridViewDataColumn Header="Assunto" Width="0.8*">
                                            <telerik:GridViewDataColumn.CellTemplate>
                                                <DataTemplate>
                                                    <StackPanel>
                                                        <TextBlock Text="{Binding ConteudoProp}" Margin="5 0 0 0" TextWrapping="Wrap"/>
                                                        <HyperlinkButton Content="{Binding NumeroAnexos}" Command="{Binding Path=DataContext.CmdVerAnexos,ElementName=LayoutRoot}" Margin="5 5 0 0" ToolTipService.ToolTip="Clique para ver os anexos associados ao assunto" FontSize="10"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn Header="Aprovado" Width="0.2*">
                                            <telerik:GridViewDataColumn.CellTemplate>
                                                <DataTemplate>
                                                    <StackPanel>
                                                        <TextBlock Text="{Binding AprovadoProp,Converter={StaticResource ConverteIntEmString}}" TextWrapping="Wrap" HorizontalAlignment="Center"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                        
                                    </telerik:RadGridView.Columns>
                                </telerik:RadGridView>
                            </Grid>

Please tell me what I have wrong.

Thanks

Nelson Silva

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 20 Oct 2011, 11:25 AM
Hi Nelson,

You can try to set the Source property of the command binding and set it to your ViewModel.
Let me know in case you need any further assistance with it.
 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Nelson
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or