6 Answers, 1 is accepted
0
Hello ron klod,
You can find more information about the extension method ParentOfType<> as well as the corresponding one ChildrenOfType<> in this blog post.
Sincerely yours,
Maya
the Telerik team
You can use the extension method ParentOfType<>. For example:
private void Button_Click(object sender, RoutedEventArgs e)
{
var senderElement = e.OriginalSource as FrameworkElement;
var row = senderElement.ParentOfType<
GridViewRow
>();
if (row != null)
{
//Implement your custom logic here.
}
}
You can find more information about the extension method ParentOfType<> as well as the corresponding one ChildrenOfType<> in this blog post.
Sincerely yours,
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

Laura Edwards
Top achievements
Rank 1
answered on 11 Aug 2010, 05:58 PM
I have a similar issue.
I am opening up a radwindow when I click a button in the grid row. I would like to pass one of the row details into the rad window where a radcombobox will pick up that detail as the selected value.
I am using MVVM. Is there a way to do this?
I am opening up a radwindow when I click a button in the grid row. I would like to pass one of the row details into the rad window where a radcombobox will pick up that detail as the selected value.
I am using MVVM. Is there a way to do this?
0

ron klod
Top achievements
Rank 1
answered on 11 Aug 2010, 07:44 PM
you soluyion doesn not work,
this does not compile:
this does not compile:
var row = senderElement.ParentOfType<
GridViewRow
>();
0

Tyree
Top achievements
Rank 2
answered on 11 Aug 2010, 08:06 PM
Ron, ParentOfType<> extension lives in Telerik.Windows.Controls.dll under namespace Telerik.Windows.Controls.UIElementExtensions
Make sure you have the appropriate references and usings.
Make sure you have the appropriate references and usings.
0

Tyree
Top achievements
Rank 2
answered on 11 Aug 2010, 08:26 PM
Laura,
I would (and have) make a new xaml for your RadWindow, in doing this you can create its own VM and the properties you need to hand the data to it.
Something like (this is the DetailsWindow.xaml)
then in the codebehind (DetailsWindow.xaml.cs) something like
Then if you create a new DetailsWindow you can do DetailsWindow.SomeIncomingItem = foo. So your button click could create a new DetailsWindow and set the value. This doesn't really maintain MVVM and is merely one possibility. Technically your RadWindow is another V and should have a VM. Your main V could trigger your VM through a command to make the VM for the RadWindow which fires an event that your V is listening to and passes in the VM for the RadWindow. The event then creates a RadWindow with the VM backing it.
Does that make sense?
I would (and have) make a new xaml for your RadWindow, in doing this you can create its own VM and the properties you need to hand the data to it.
Something like (this is the DetailsWindow.xaml)
<
telerik:RadWindow
x:Class
=
"MyNamespace.DetailsWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<!-- make it look as desired -->
</
Grid
>
</
telerik:RadWindow
>
then in the codebehind (DetailsWindow.xaml.cs) something like
using
System.Windows.Controls;
using
Telerik.Windows.Controls;
namespace
MyNamespace
public
partial
class
DetailsWindow : RadWindow
{
public
DetailsWindow()
{
InitializeComponent();
}
public
object
SomeIncomingItem {
get
;
set
; }
}
}
Then if you create a new DetailsWindow you can do DetailsWindow.SomeIncomingItem = foo. So your button click could create a new DetailsWindow and set the value. This doesn't really maintain MVVM and is merely one possibility. Technically your RadWindow is another V and should have a VM. Your main V could trigger your VM through a command to make the VM for the RadWindow which fires an event that your V is listening to and passes in the VM for the RadWindow. The event then creates a RadWindow with the VM backing it.
Does that make sense?
0

Laura Edwards
Top achievements
Rank 1
answered on 11 Aug 2010, 09:39 PM
It kind of makes sense. I'm still a little confused.
In MainPage.xaml.cs (where MainPage.xaml contains the gridview), I call a new window:
deleteCategoryWindow is the window where I have the DDL that I want to populate with the selected value from the grid. Also the DDL is bound to a list in it's view model. How do I pass the grid's selected Item to the window?
Thanks for your help.
In MainPage.xaml.cs (where MainPage.xaml contains the gridview), I call a new window:
deleteCateoryWindow = new DeleteCategory();
deleteCateoryWindow.ShowDialog();
Thanks for your help.