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

[Solved] How to use a RadWindow as an external DetailsPresenter

1 Answer 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
devster
Top achievements
Rank 1
devster asked on 01 Dec 2009, 09:29 AM

 

 

Can this be done?

- start with a GridView
- wire up a details presenter containing a RadWindow
ExternalDetailsPresenter.DetailsProvider = EventGridView.RowDetailsProvider

 

 

<

 

GridView:DetailsPresenter x:Name="ExternalDetailsPresenter">

 

 

 

<telerikNavigation:RadWindow

 

 

 

WindowStartupLocation="CenterScreen">

 

 

 

<StackPanel>

 

 

 

<TextBlock Text="{Binding Id}" />

 

 

 

</StackPanel>

 

 

 

</telerikNavigation:RadWindow>

 

 

 

</GridView:DetailsPresenter>

Expected result: when detail is triggered, a new Window is displayed containing the StackPanel and TextBlock, bound to the row detail data.

Actual result: entire grid is replaced by gray "header" zone and black "content" zone.

As a bonus question: if this can be achieved, how can you control modal/not modal behavior of the window in this scenario?

 

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Dec 2009, 04:33 PM
Hello dev,

I cannot understand this. One would want to place the DetailsPresenter in a RadWindow and not the other way around. The DetailsPresenter is a control in which you see your RowDetailsTemplate materialized and you are not supposed to place things inside it. Please, take a look at the Row Details Demo and click External Details Presenter -> Visible. To learn more about Row Details you can consult  the help topic.

I have prepared and attached a sample project with a RadWindow with DetailsPresenter inside it. The project is very basic, but you can use it as a base. You can further customize the RadWindow by following this help article.

Here is the important stuff:

using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.GridView;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
 
namespace TicketID_263115_ExternalDetailsPresenterInARadWindow
{
    public partial class MainPage : UserControl
    {
        RadWindow window;
         
        public MainPage()
        {
            InitializeComponent();
 
            this.window = new RadWindow();
            this.window.Content = new DetailsPresenter() { DetailsProvider = this.clubsGrid.RowDetailsProvider };
            this.clubsGrid.RowDetailsProvider.PropertyChanged += this.OnRowDetailsProviderPropertyChanged;
 
            this.clubsGrid.ItemsSource = Club.GetClubs();
        }
 
        void OnRowDetailsProviderPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "DataContext")
            {
                Club currentClub = this.clubsGrid.RowDetailsProvider.DataContext as Club;
                if (currentClub != null)
                {
                    var currentRow = this.clubsGrid.ItemContainerGenerator.ContainerFromItem(currentClub) as GridViewRow;
                    var lastCell = currentRow.Cells[currentRow.Cells.Count - 1];
                    GeneralTransform generalTransform = lastCell.TransformToVisual(Application.Current.RootVisual);
                    Point childToParentCoordinates = generalTransform.Transform(new Point(lastCell.ActualWidth + 1, 1));
                    this.window.Left = childToParentCoordinates.X;
                    this.window.Top = childToParentCoordinates.Y;
                    this.window.Show();
                }
                else
                {
                    this.window.Hide();
                }
            }
        }
    }
}

I hope this helps.

Greetings,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
devster
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or