Can´t binding a command inside Cell Template

2 posts, 0 answers
  1. Nelson
    Nelson avatar
    62 posts
    Member since:
    Apr 2011

    Posted 20 Oct 2011 Link to this post

    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
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Oct 2011 Link to this post

    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 >>

Back to Top