Button Command in Datatemplate not firing

2 posts, 0 answers
  1. Tomasz
    Tomasz avatar
    20 posts
    Member since:
    Apr 2012

    Posted 17 Aug 2015 Link to this post

    Hi,

     

    I have this structure as defined below. The issue is with the buton down at the bottom as it's not firing the "SendKudosCommand" which I have defined in my ViewModel. I have another buton defined outside the scope of the ListBox and it fires up with no issue. Any suggestions?

    <telerikData:RadDataBoundListBox>
     
                            <telerikData:RadDataBoundListBox.ItemTemplate>
                                <DataTemplate>
     
                                    <Border
                                        ...>
     
                                        <telerik:RadExpanderControl
                                            ...>
                                            <telerik:RadExpanderControl.ContentTemplate>
     
                                                <DataTemplate>
     
                                                    <Grid>
     
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width=".2*"/>
                                                            <ColumnDefinition Width=".6*"/>
                                                        </Grid.ColumnDefinitions>
     
     
     
                                                        <Ellipse
                                            ...>
                                                            <Ellipse.Fill>
                                                                <ImageBrush
                                                    ImageSource="{Binding UserPhoto}"
                                                    Stretch="UniformToFill"/>
                                                            </Ellipse.Fill>
                                                        </Ellipse>
     
                                                        <StackPanel
                                            ...>
     
                                                            <TextBlock
                                                .../>
                                                            <TextBlock
                                                .../>
                                                            <TextBlock
                                                .../>
     
                                                        </StackPanel>
     
                                                    </Grid>
                                                </DataTemplate>
     
                                            </telerik:RadExpanderControl.ContentTemplate>
     
                                            <telerik:RadExpanderControl.ExpandableContentTemplate>
                                                <DataTemplate>
     
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition/>
                                                            <RowDefinition/>
                                                            <RowDefinition/>
                                                        </Grid.RowDefinitions>
     
                                                        <StackPanel
                                                            Orientation="Vertical"
                                                            Grid.Row="0">
     
                                                            <TextBlock
                                                                .../>
     
                                                            <ComboBox>
                                                                ...
                                                            </ComboBox>
     
                                                        </StackPanel>
     
                                                        <StackPanel
                                                            Orientation="Vertical"
                                                            Grid.Row="1">
     
                                                            <TextBlock
                                                                .../>
                                                            <TextBox                                                           
    .../>
     
                                                        </StackPanel>
                                                         
                                                        <Button
                                                            Grid.Row="2"
                                                            Content="Send"
                                                            HorizontalAlignment="Right"
                                                            Command="{Binding SendKudosCommand}"/>
     
                                                    </Grid>
     
                                                </DataTemplate>
                                            </telerik:RadExpanderControl.ExpandableContentTemplate>
     
                                        </telerik:RadExpanderControl>
     
                                    </Border>
     
                                </DataTemplate>
                            </telerikData:RadDataBoundListBox.ItemTemplate>
     
                        </telerikData:RadDataBoundListBox>

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 20 Aug 2015 Link to this post

    Hi Tomasz,

    The first thing to check in such scenario is the data context of the button. You can check it using a custom converter in the questionable binding. In the converter you will be able to set a break point. It will allow you to see what data object comes in the binding. Please keep in mind that the object that comes in the binding should expose the command in order to allow the button to trigger it.  If the command is not there you should restructure your view model in a way that the object that you bind to exposes the command.

    I hope this information will get you started.

    Regards,
    Pavel R. Pavlov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top