Welcome to the Xceed Community Sign in | Join | Help
Community Search  

How to get ref to the InsertionRow?

Sort Posts: Previous Next
  •  03-24-2008, 8:14 AM Post no. 11283

    How to get ref to the InsertionRow?

    Given a DataGridControl, is there a way to get a reference to its InsertionRow?

    Or, given an InsertionRow, I can override EndInit or somesuch to get some code in there, but is there any way to get the DataGridControl it's being created for?

    If it was just created once, I could exploit the timing locality between the creation of the two objects and snag a reference that way, but I'm assuming virtualization means old refs to InsertionRow may become invalid and new ones created at unpredictable times, so I need an on-the-fly solution.
  •  03-25-2008, 8:26 AM Post no. 11284 in reply to 11283

    Re: How to get ref to the InsertionRow?

    If you want to get a reference to the InsertionRow in the headers of a grid, you will need to handle the InsertionRow's Loaded event and retrieve the reference there.

    To get a reference to an item's parent DataGridControl, you can either get its DataGridContext and check the ParentDataGridControl property or you can use the GetParentDataGridControl attached property defined on the DataGridControl class.
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  03-26-2008, 1:22 AM Post no. 11285 in reply to 11284

    Re: How to get ref to the InsertionRow?

    InsertionRow's Loaded event - okay, how do you set this? There doesn't seem to be a Loaded virtual method; one can do row.Loaded += ... - but the code to do that, needs to be put somewhere else such as EndInit?

    InsertionRow doesn't seem to have a DataGridContext member?
  •  03-26-2008, 9:07 AM Post no. 11286 in reply to 11285

    Re: How to get ref to the InsertionRow?

    You can do it that way:

    <DataTemplate>
    <xcdg:InsertionRow Loaded="MyLoadedHandler" />
    </DataTemplate>
    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  03-26-2008, 9:33 AM Post no. 11287 in reply to 11286

    Re: How to get ref to the InsertionRow?

    Right, that should work for the Loaded handler, thanks - I assume Loaded is called exactly once every time a new InsertionRow is created for a given data grid because of virtualization?

    That still leaves the problem of obtaining a handle to the InsertionRow from DataGridControl, or to the DataGridControl from InsertionRow - is there a way to do either of these things? InsertionRow doesn't have a DataGridContext member, and as far as I can tell from a Google search, ParentDataGridControl is only a property of class Column.
  •  03-26-2008, 12:40 PM Post no. 11288 in reply to 11287

    Re: How to get ref to the InsertionRow?

    Further investigation... according to:
    http://doc.xceedsoft.com/products/XceedWpfDataGrid/Migrating_from_version_1.x.html

    Column.ParentDataGridControl no longer exists; the replacement is said to be DataGridControl.GetParentDataGridControl. But how is that a replacement? You can't call it unless you already have the DataGridControl reference, in which case you don't need to call it.
  •  03-26-2008, 1:55 PM Post no. 11289 in reply to 11288

    Re: How to get ref to the InsertionRow?

    It is a static method :)
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  03-26-2008, 7:24 PM Post no. 11290 in reply to 11289

    Re: How to get ref to the InsertionRow?

    You're right, so it is.

    void InsertionRow_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
    var grid = DataGridControl.GetParentDataGridControl(sender as DependencyObject);
    }

    And then I can store a reference to the InsertionRow in the original DataGridControl. Thanks!
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.