5 Answers, 1 is accepted
0

Rahul
Top achievements
Rank 1
answered on 13 Apr 2011, 07:38 AM
Hi,
Attaching a code ...
Command is not getting fired on click event.
Please help.
<
telerik:RadGridView
Grid.Row
=
"2"
x:Name
=
"orderView"
ItemsSource
=
"{Binding Order}"
AutoGenerateColumns
=
"False"
CanUserDeleteRows
=
"{Binding IsChecked, Mode=TwoWay, ElementName=CanUserDeleteRowsCheckBox}"
IsReadOnly
=
"{Binding IsChecked, Mode=TwoWay, ElementName=IsReadOnlyCheckBox}"
SelectionMode
=
"Extended"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewToggleRowDetailsColumn
/>
<
telerik:GridViewSelectColumn
Header
=
"Select"
x:Name
=
"chkbox"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding CustomerName}"
Header
=
"Name"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Age}"
Header
=
"Age"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=COActivity.ActivityDescription}"
Header
=
"Age"
/>
</
telerik:RadGridView.Columns
>
<
telerik:RadGridView.RowDetailsTemplate
>
<
DataTemplate
>
<
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Label
Content
=
"Enter Name"
/>
<
TextBox
Height
=
"25"
Width
=
"200"
Background
=
"AliceBlue"
Text
=
"{Binding CustomerName}"
/>
</
StackPanel
>
<
StackPanel
Orientation
=
"Horizontal"
>
<
Label
Content
=
"Enter Age"
/>
<
TextBox
Height
=
"25"
Width
=
"200"
Background
=
"AliceBlue"
Text
=
"{Binding Age}"
/>
</
StackPanel
>
<
Button
Height
=
"25"
Width
=
"80"
Content
=
"Save"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"Click"
>
<
cmd:EventToCommand
Command
=
"{Binding Path=SaveCommand}"
PassEventArgsToCommand
=
"True"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
Button
>
</
StackPanel
>
</
DataTemplate
>
</
telerik:RadGridView.RowDetailsTemplate
>
</
telerik:RadGridView
>
private RelayCommand<
RoutedEventArgs
> _saveCommand;
public RelayCommand<
RoutedEventArgs
> SaveCommand
{
get
{
if (_saveCommand == null)
{
_saveCommand = new RelayCommand<
RoutedEventArgs
>(param => this.SaveOrder(param));
}
return _saveCommand;
}
}
private void SaveOrder(RoutedEventArgs e)
{
System.Windows.MessageBox.Show("Hi");
}
0
Hello Rahul,
Best wishes,
Maya
the Telerik team
Is the command defined in your ViewModel ? May you try to do the following:
<
Window.Resources
>
<
local:MyViewModel
x:Key
=
"MyViewModel"
/>
</
Window.Resources.
<cmd:EventToCommand
Command
=
"{Binding Path=SaveCommand, Source={StaticResource MyViewModel}}"
PassEventArgsToCommand
=
"True"
/>
Best wishes,
Maya
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
0

Rahul
Top achievements
Rank 1
answered on 15 Apr 2011, 07:20 AM
Hi Maya ,
its woking fine after defining a Source={StaticResource MyViewModel}, but i couldnt understsnd when same command is fired outside the RowDetailsTemplete, its getting fired, is it like commad defined inside a RowDetailsTemplete wont get a DataContext set?
its woking fine after defining a Source={StaticResource MyViewModel}, but i couldnt understsnd when same command is fired outside the RowDetailsTemplete, its getting fired, is it like commad defined inside a RowDetailsTemplete wont get a DataContext set?
0

Rahul
Top achievements
Rank 1
answered on 18 Apr 2011, 07:12 AM
Hi Maya,
As you suggested, i need to again create a new instance of viewmodel and set a datacontext to command. As my Item collection is bind to RowDetails Templete, it dont need to set the datacontext again .But in both the cases, i need to have only one viewmodel instance.
Please help.
As you suggested, i need to again create a new instance of viewmodel and set a datacontext to command. As my Item collection is bind to RowDetails Templete, it dont need to set the datacontext again .But in both the cases, i need to have only one viewmodel instance.
Please help.
0
Hello Rahul,
Maya
the Telerik team
The reason that a command defined in your ViewModel is not fired from the RowDetails is that the context is different. While the DataContext for the main grid is the ViewModel, for the grid in the details it is the corresponding item from the parent grid. What you may try to do is to define ViewModel only as a resource in xaml and set the DataContext here. Yet another possibility would be to handle the Click event of the button and execute the command from the code-behind.
Maya
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