Hi,
i would like to add a menu to a specific column, create the event click for the command and copy a string inside the value column in the position set with the mouse before.
Best regards
Gian Piero Truccolo
|
<syncfusion:SfDataGrid.RecordContextMenu>
<ContextMenu Style="{x:Null}">
<MenuItem Command="{Binding Source={x:Static Member=local:ContextMenuCommands.Copy}}"
CommandParameter="{Binding}"
Header="Copy">
</MenuItem>
</ContextMenu>
</syncfusion:SfDataGrid.RecordContextMenu> |
|
private void OnGridContextMenuOpening(object sender, GridContextMenuEventArgs e)
{
//here customized based on your scenario
var dataGrid = sender as SfDataGrid;
//here context menu only showed for EmployeeName Column
if (dataGrid.Columns[e.RowColumnIndex.ColumnIndex].MappingName != "EmployeeName")
e.Handled = true;
} |
Hi,
what i want to do is little different, i attach an image with the three steps.
I would like to overrìde tha context menu or replace that with another one.
Best regards
Gian Piero Truccolo
|
<Window.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu >
<MenuItem Command="Cut" />
<MenuItem Command="Copy" />
<MenuItem Command="Paste" />
<MenuItem Header="{Binding GetCopiedText ,Source={StaticResource employeeInfoViewModel}}"
Command="Paste" />
</ContextMenu>
</Setter.Value>
</Setter>
</Style>
</Window.Resources> |
|
public class EmployeeInfoViewModel : INotifyPropertyChanged
{
private string getCopiedText;
public string GetCopiedText
{
get
{
return getCopiedText;
}
set
{
getCopiedText = value;
OnPropertyChanged("GetCopiedText");
}
}
}
private static void OnCopyClicked(object obj)
{
if (obj is GridRecordContextMenuInfo)
{
var grid = (obj as GridRecordContextMenuInfo).DataGrid;
grid.GridCopyPaste.Copy();
//here change the text based on recently copied text
(grid.DataContext as EmployeeInfoViewModel).GetCopiedText = Clipboard.GetText();
}
} |
Hi Vijayarasan,
but in my case the source where i copy text is a list view(window standard) and then i would like to paste the inside the grid column.
Best regards
Gian Piero Truccolo