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

Cannot open ContextMenu from inside DataGrid CellEditing Template?

1 Answer 51 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 06 Oct 2010, 07:08 PM
I am having a problem trying to open a ContextMenu inside a DataGrid...

The following code works properly when it exists other places in my application.
<ToggleButton Grid.Column="1" Content="Click Me!" Height="20" Width="100" IsChecked="{Binding IsOpen, ElementName=rcm, Mode=TwoWay}" >
  <telerik:RadContextMenu.ContextMenu>
    <telerik:RadContextMenu x:Name="rcm" Placement="Bottom">
      <telerik:RadMenuItem Header="Item1" />
      <telerik:RadMenuItem Header="Item2" />
      <telerik:RadMenuItem Header="Item3" />
    </telerik:RadContextMenu>
  </telerik:RadContextMenu.ContextMenu>
</ToggleButton>

However if I place this code inside a DataGrid (specifically a CellEditingTemplate of a DataGridTemplateColumn, it does not work - i.e: the menu never opens.
<sdk:DataGrid RowHeight="100" AutoGenerateColumns="False" ItemsSource="{Binding Collection}" >
  <sdk:DataGrid.Columns>
    <sdk:DataGridTemplateColumn>
      <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
          <TextBlock Foreground="Red" Text="{Binding Property1}" />
        </DataTemplate>
      </sdk:DataGridTemplateColumn.CellTemplate>
      <sdk:DataGridTemplateColumn.CellEditingTemplate>
        <DataTemplate>
          <Grid>
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="1*" />
              <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>
            <TextBox Foreground="Red" Text="{Binding Property1, Mode=TwoWay}" />
            <ToggleButton Grid.Column="1" Content="Button" Height="20" Width="100" IsChecked="{Binding IsOpen, ElementName=rcm, Mode=TwoWay}" >
              <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="rcm" Placement="Bottom" >
                  <telerik:RadMenuItem Header="Item1" />
                  <telerik:RadMenuItem Header="Item2" />
                  <telerik:RadMenuItem Header="Item3" />
                </telerik:RadContextMenu>
              </telerik:RadContextMenu.ContextMenu>
            </ToggleButton>
          </Grid>
        </DataTemplate>
      </sdk:DataGridTemplateColumn.CellEditingTemplate>
    </sdk:DataGridTemplateColumn>
  </sdk:DataGrid.Columns>
</sdk:DataGrid>

asdasd
asdasd

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 10 Oct 2010, 09:50 PM
Hello Rob,

This looks like problem in the DataGrid control. When RadContextMenu opens it will take focus so that keyboard navigation works but this cause DataGrid to think that edited row lost focus and will return the cells to cell template which will cause RadContextMenu to unload and close.

I will let you know if I find a workaround for this case.

Kind regards,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Menu
Asked by
Rob
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or