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

Button Command in Datatemplate not firing

1 Answer 163 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tomasz
Top achievements
Rank 1
Tomasz asked on 17 Aug 2015, 02:12 PM

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>

1 Answer, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 20 Aug 2015, 07:00 AM
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
Tags
DataBoundListBox
Asked by
Tomasz
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or