Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Get the column name from DataRecordCellArea when creating dynamic Context Menu.
posted

I am creating a dynamic context menu for a XamDataGrid.  I need to know what column the cell they are right clicking on is in.  Here is Xaml And Code Behind...

 <igDP:XamDataGrid  x:Name="XamDataGrid1"

                                   DataSource="{Binding Model.QueryResults}"

                                   Background="Transparent"

                                   Theme="Office2k7Black">

                    <igDP:XamDataGrid.Resources>

                        <Style TargetType="{x:Type igDP:DataRecordCellArea}"  >

                            <EventSetter Event="ContextMenu.ContextMenuOpening" Handler="cm_ContextMenuOpening"></EventSetter>

                            <Setter Property="ContextMenu">

                                <Setter.Value>

                                    <StaticResourceExtension ResourceKey="cmenu"></StaticResourceExtension>

                                </Setter.Value>

                            </Setter>

                        </Style>

                    </igDP:XamDataGrid.Resources>

 

 

                    <igDP:XamDataGrid.FieldSettings>

                        <igDP:FieldSettings AllowEdit="False" />

                    </igDP:XamDataGrid.FieldSettings>

                    <igDP:XamDataGrid.FieldLayoutSettings>

                        <igDP:FieldLayoutSettings HighlightAlternateRecords="True"/>

                    </igDP:XamDataGrid.FieldLayoutSettings>

                </igDP:XamDataGrid>

 

 CODE BEHIND:

void cm_ContextMenuOpening(object sender, ContextMenuEventArgs e)

        {

            DataRecordCellArea item = sender as DataRecordCellArea;

            DataRecord dataRecord = item.Record;

            ContextMenu cm = item.ContextMenu;

            cm.Items.Clear();

<NEED TO ACCESS COLUMN INFO HERE>

Parents
  • 69686
    posted

    Hello,

    Perhaps you can create the style for the CellValuePresenter instead of the DataRecordCellArea and this way your sender will be the CellValuePresenter which you have clicked on. It exposes Record and Field properties which will help you determine which cell was clicked.

Reply Children
No Data