I'm using a RadGridView with a custom RowDetail template that contains buttons for performing editing functions. I want to be able to call a function that is located within the XAML that contains the parent grid to let it know that some editing has been done and completed.
4 Answers, 1 is accepted
0
Hi Lee Weisenberger,
From within your row details control, you can find the parent grid with the ParentOfType<RadGridView>() extension method and do anything to it. The extension method is in the Telerik.Windows.Controls namespace.
Let me know if there are problems.
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.
From within your row details control, you can find the parent grid with the ParentOfType<RadGridView>() extension method and do anything to it. The extension method is in the Telerik.Windows.Controls namespace.
Let me know if there are problems.
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.
0
Lee
Top achievements
Rank 1
answered on 09 Apr 2010, 03:36 PM
I'm sorry, I misspoke when I said I wanted to access a function within the XAML. I meant to say that I want to access a function within the codebehind for the XAML.
I have a public helper function in the MainPage.xaml.cs that is used to make some updates to private variables and then post those changes to a database. Is there a way to call the public helper function from the RowDetails template codebehind?
Thanks.
0
Accepted
Hi Lee Weisenberger,
The "function within the codebehind for the XAML" is a member of the user control that RadGridView is inside. So find this top-level user control with the ParentOfType<T> method. This is the control that owns the methods that you are talking about. Then execute them:
var mainWindow = this.ParentOfType<Window1>();
mainWindow.DoSomething();
I hope this helps.
Regards,
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.
The "function within the codebehind for the XAML" is a member of the user control that RadGridView is inside. So find this top-level user control with the ParentOfType<T> method. This is the control that owns the methods that you are talking about. Then execute them:
var mainWindow = this.ParentOfType<Window1>();
mainWindow.DoSomething();
I hope this helps.
Regards,
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.
0
Lee
Top achievements
Rank 1
answered on 09 Apr 2010, 04:33 PM
Thanks Ross! That's what I was looking for.
I did have to make one change to code to get it to work from within the codebehind of the RowDetail template.
In my case, I needed use the following code:
var parentGrid = this.ParentOfType<RadGridView>(); // Parent grid for the RowDetail |
var mainWindow = parentGrid.ParentOfType<Window1>(); // this.ParentOfType<Window1>() returns null, use parentGrid instead of "this" keyword |
mainWindow.DoSomething(); |
Thanks again.