Hi,
I'm currently looking into the possibilities of xamWebGrid.
I like the Multiple Cell Selection mode to achieve something similar that is available in Excel. However, when the multiple cell selection is finished I must somehow be able to copy/paste the contents of the first selected cell over the other selected cells. Is this possible with xamWebGrid (eg a right click Context Menu with copy/paste, etc)
Thanks,
Nicolas
Nicolas,
The following thread provides more information about clipboard operations in Silverlight, originally in the context of copying/pasting between xamWebGrid and Excel:http://forums.infragistics.com/forums/t/30957.aspx
Actually,
What I'm trying to do is copy/paste operations inside the same xamWebGrid. (without using the clipboard)
I'm trying to do this with a context menu. I want to add a context menu when a Row Selector is clicked (eg Copy Row) and a different context menu when a regular Cell is clicked (eg Copy Cell)
Can you help me with an approach for doing this ?
Hi Nicolas,
So, as you may know we added a ContextMenu in our 9.2 release.
If you simply want to display a ContextMenu when somone left clicks on a RowSelector, you can use the following code: Which uses the RowSelectorClicked event.
XamWebContextMenu xwc;
public MainPage()
{
InitializeComponent();
xwc = new XamWebContextMenu();
xwc.Items.Add("Copy");
xwc.Items.Add("Paste");
ContextMenuManager manager = new ContextMenuManager();
manager.ContextMenu = xwc;
ContextMenuService.SetManager(this.DataGrid1, manager);
}
private void DataGrid1_RowSelectorClicked(object sender, Infragistics.Silverlight.RowSelectorClickedEventArgs e)
xwc.IsOpen = true;
You can also use the CellClicked event for displaying your alternate menu. Now, the code i have here is simplified. You'll probably want to create another menu, and make the manager a member variable, so that you can switch out the Contextmenu on the manager in the event that you're displaying the menu.
Now, if you want to display the menu for a right click, you'll have to use a different approach.
You can use the Opening event of the XamWebContextMenu:
<igMenu:ContextMenuService.Manager>
<igMenu:ContextMenuManager OpenMode="RightClick" >
<igMenu:ContextMenuManager.ContextMenu>
<igMenu:XamWebContextMenu Opening="xwc_Opening">
<igMenu:XamWebMenuItem Header="Copy"></igMenu:XamWebMenuItem>
<igMenu:XamWebMenuItem Header="Paste"></igMenu:XamWebMenuItem>
</igMenu:XamWebContextMenu>
</igMenu:ContextMenuManager.ContextMenu>
</igMenu:ContextMenuManager>
</igMenu:ContextMenuService.Manager>
void xwc_Opening(object sender, Infragistics.Silverlight.OpeningEventArgs e)
List<RowSelectorCellControl> rowSelectors = e.GetClickedElements<RowSelectorCellControl>();
if (rowSelectors.Count > 0)
// RowSelector
return;
List<CellControl> normalCells = e.GetClickedElements<CellControl>();
if (normalCells.Count > 0)
// Normal Cell
e.Cancel = true;
Now, in order for the right click menu to work, you need to make sure that the Silverlight Plugin has it's windowless property set to true:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="windowless" value="true" />
-SteveZ