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

Commands in datatemplate

2 Answers 73 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Dom
Top achievements
Rank 1
Dom asked on 28 Oct 2011, 06:25 PM
Hi,

I have a list of tabs (binding on a collection)
in each tab I have a control with a command.
Problem is command doesn't seem to work, it never launches.

Here's a simple examble that works :


       <telerik:RadTabControl >
                                <telerik:RadTabItem Header="Test">
                                    <Button Content="Test" Command="{Binding CharacteristicMenu}" CommandParameter="Add" />
                                </telerik:RadTabItem>
                            </telerik:RadTabControl>

and here's one close to what I want to do that doesn't work :

  <telerik:RadTabControl ItemsSource="{Binding Tabs}">
                                <telerik:RadTabControl.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <TextBlock Text="{Binding Path=Name.Text, Mode=TwoWay}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:RadTabControl.ItemTemplate>
                                <telerik:RadTabControl.ContentTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <StackPanel>
                                                <Button Content="Test" Command="{Binding CharacteristicMenu}" CommandParameter="Add" />
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </telerik:RadTabControl.ContentTemplate>
    </telerik:RadTabControl>

I can't seem to make the commands works inside a datatemplate. I need to get commands to work with a button and with your contextuelmenu.
Is it a limitation of the tabcontrol or something? I tried a radbutton instead of button with no success (which wouldn't of fixed the problem with a contextuelmenu anyway).

Thanks
Dom

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 02 Nov 2011, 02:58 PM
Hi Dom,

I wasn't able to reproduce this issue on our side. It might be related to the structure of your view models and the business data. I prepared a sample project - please have a look at it and let me know if it works for you or if I'm missing something.

Greetings,
Tina Stancheva
the Telerik team

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

0
Dom
Top achievements
Rank 1
answered on 04 Nov 2011, 07:00 PM
Tried your project, seems to be what I want, i added the docking around it, and it still works.

I compared yours to mine, and problem seems to be that I put the command/Delegate in the mainviewmodel (didn't have a view model for each tabs, just had the data for each to bind).

It seems to be the problem so I'll try changing that.
Tags
TabControl
Asked by
Dom
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Dom
Top achievements
Rank 1
Share this question
or