Welcome to the Xceed Community | Help
Community Search  
More Search Options

simple grid question

Sort Posts: Previous Next
  •  05-10-2010, 10:46 AM Post no. 26781

    simple grid question

    hi,

    I am trying to have one of the columns to behave as a "link" to a line data point chart that opens in a new window (sort of master/detail like behavior).  The chart would be bound to one of the properties of the object bound to the given row. I am not sure how to proceed.  The property is a KeyValuePair collection.  It should be pretty simple but was not able to find any information in the forum or online.

     My idea would be to have some image or button in the cell with a click event that generates the chart in a new window.  Would this be possible?

    Please help.

     Thanks,

    Julien

    Filed under: , ,
  •  05-11-2010, 4:40 PM Post no. 26798 in reply to 26781

    Re: simple grid question

    Hi Julien, 

    One way you can achieve this is through the following:

    Lets call your first window, the one that contains the grid “GridWindow”.

    Create a new window and name it “ChartWindow”.

    Create a Constructor that takes as parameter a"KeyValuePair" collection in ChartWindow. 

    Subscribe to the PreviewMouseDown event of the DataCell in GridWindow. This canbe done through styles and event setters. Here's an example: 

    <Style TargetType="xcdg:DataCell">

                <EventSetterEvent="PreviewMouseDown"

                           Handler="DataCellPreviewMouseDownHandler"/>

    </Style> 

    In the handler, Extract the object that represents the clicked cell, create anew ChartWindow class and send the KeyValue collection property of thatobject through the constructor. Here's an example: 

        private voidDataCellPreviewMouseDownHandler(object sender, RoutedEventArgs e)

        {

            Xceed.Wpf.DataGrid.DataCell cell= sender as Xceed.Wpf.DataGrid.DataCell;

            NewWindow window = newNewWindow(((YourType)cell.DataContext).YourKeyValueCollection);

            window.Show();

        }

    In the constructor of ChartWindow, set the properties of yourchart as needed from the YourKeyValueCollection that is sent as parameter.

    Don’t forget to call InitializeComponent  in your constructor.

    I hope this was clear and answers your question.


    Best Regards,

    Michel Dahdah
    Technical Support
    Xceed Software inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.