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

GridView / Prism question

1 Answer 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark Westwood
Top achievements
Rank 1
Mark Westwood asked on 12 Feb 2010, 05:05 PM
Hi,

I have a gridview using the </gridView:RadGridView.RowDetailsTemplate> to display finer details about the item in the grid row. This works fine. inside this template I also have a button which has an attached command:

<Button Margin="2,2,2,2" Padding="5,5,5,5" Style="{DynamicResource SimpleButton}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
                                    x:Name="DeleteTaskButton" FontWeight="Normal" Foreground="#505050" FontSize="14" FontFamily="Corbel"
                                    Content="Delete Task Schedule"
                                    commands:Click.Command="{Binding DeleteTaskCommand}"
                                    commands:Click.CommandParameter="{Binding Id}"/>

Here I can pass the Id of the Item to my backing ViewModel and remove from the collection. However, this currently doesn't work because the DelegateCommand is part of the ViewModel NOT the object being rendered by the DataTemplate. Obviously I could add the command to the object but I don't like it as it gets quite messy, my base object has already had INotifyPropertyChanged added to it. Ideally what I would like is a way have the button command in my ViewModel picking up the command from the DataTemplate, and also if possible I would like to be able to retrieve the SelectedIndex of the GridView.

Thanks, Mark

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 15 Feb 2010, 08:31 AM
Hello Mark Westwood,

The element loaded from the RowDetails DataTemplate gets the respective data item (row) as its DataContext. Do this data item should have the command, I guess.

We cannot think of another way to handle your command apart from adding it to your details object. DataTemplates are part of the WPF Framework and we have no control over their behavior. In case you have an idea about how to overcome this limitation, we would be glad to hear it and we might consider implementing it for a future version.

Greetings,
Ross
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Mark Westwood
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or