Hello,
I would like to create two commands that will take as parameter a XamGrid and
1) Show the columnchooser for that grid
2) Export data to excel..
Those commands should be invoked by a context menu item or a simple button or a ribbon tool or whatever element is supported by the commanding framework.
I have tried to do so, but with no success...
Is it that difficult?
What am i missing?
Regards,
Michael
Thank you Steve.
Hi Michael,
So Target is of type object, so setting a binding on it, is actually just making the Target property equal to a binding.
However, you can use the Attached CommandTarget property and put it on your button, like so:
<Button Content="Column Chooser" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="149" ig:Commanding.CommandTarget="{Binding ElementName=xamGrid1}">
<ig:Commanding.Command>
<ig:ColumnChooserCommandSource EventName="Click" />
</ig:Commanding.Command>
</Button>
Hope this helps,
-SteveZ
Hello Steve,
what i did was to inherit from XamGrid and support the two commands.
The only thing that you set on xaml is the targetname.
I also cannot bind target to grid when i use the command source on a button. Is that Normal?
Suggestion:
Please implement ICommandTarget on XamGrid in order to support these types of commands...
Also in the column Chooser window, it would be nice if you could select(navigate and edit) a nested column layout
PS
I attach a sample with the implementation. It also shows the problem with Target binding on a Button element...
Thanx
The problem with ContextMenu is that it doesn't actually live in the VisualTree, it lives in a popup outside of it.
What this means, is that it can't participate in normal bindings, that involve DataContext inheritance or ElementName bindings.
On top of that, it can't resolve it's CommandTarget either.
Check out this help topic on how the CommandTarget is resolved.
http://help.infragistics.com/NetAdvantage/Silverlight/2010.3/CLR4.0/?page=SL_xamGrid_About_Infragistics_Commanding.html
Your best bet is probably to use the TargetName property on your commandSOurce
Then register yourself with the CommandSourceManager:
public MainPage()
{
CommandSourceManager.RegisterCommandTarget(this);
InitializeComponent();
}
i implemented the attached sample...
It has a Grid and a context menu in it, a button and a xamGridEx (an inherited xamGrid that implements ICommandTarget and supports ColumnChooserCommand) with a context menu in it.
The context menus has an item with a column chooser command source.
Also the button has a column chooser command source.
The button works as expected, but the menu items do nothing....
Have i done something wrong?
I have an application that shows at least 15 grids with a Context Menu that will export the contents of the grids or will show the column chooser command....
What should i do in order to support this common scenario?
Regards