In one of my previous blog posts I have explained how to display hierarchical data with Row Details. Now, if you are familiar with Row Details features, you know that you are not limited to showing the details inside RadGridView. You can show them anywhere by using the handy external DetailsPresenter. As a matter of fact, each GridViewRow has one of those DetailsPresenter’s inside its template. So you will be using the same class that we are using internally to show the details of each single row.
The documentation states that in order to display Row Details outside RadGridView, you need to place a DetailsPresenter control somewhere around RadGridView and wire them up. Well, it does not need to be around, really. Let’s place it in Telerik’s RadWindow:
The DetailsPresenter cares about three things – what is the DataTemplate it needs to load, whether it is visible or not, and what is its DataContext. All this information comes through its DetailsProvider property which is assigned from RadGridView’s respective property RowDetailsProvider. This means that this particular DetailsPresenter will be fed by this particular RadGridView. Let’s take a look at the interface:
In case you have not noticed, it inherits from the INotifyPropertyChanged interface. Each time a row is selected in RadGridView, the DataContext of the DetailsProvider changes. The DetailsPresenter listens for these property changes and updates as needed. We can listen for a PropertyChanged ourselves and position the window accordingly:
That’s about all you need to do. Below you can see the RadGridView+RadWindow combo in action. Fell free to play with the window. When you select another row it will be brought back to where it belongs. Ctrl-click a selected row to deselect it and the window will disappear.
You can find the full source code here.
Subscribe to be the first to get our expert-written articles and tutorials for developers!