TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vinodh soundararajan
NA
1
6.1k
WPF DataGrid Binding with Context Menu argument
Aug 7 2014 10:12 AM
I have a ContextMenu inside DataGrid, I need to pass the selected items, selected cells as an argument to my Delegate comments. When i try with the following code. i am getting an BindingError as "Cannot find source for binding with reference 'ElementName=m_dsGrid'. BindingExpression:Path=SelectedItems.Cells; DataItem=null; target element is 'MenuItem' (Name=''); target property is 'CommandParameter' (type 'Object')"
<dp:XamDataGrid DataSource="{Binding CustomerCollection}" IsSynchronizedWithCurrentItem="True" GroupByAreaLocation="None"
ActiveDataItem="{Binding SelectedCustomer, UpdateSourceTrigger=PropertyChanged, Source=.}">
<dp:XamDataGrid.FieldLayoutSettings>
<dp:FieldLayoutSettings AutoGenerateFields="False" SelectionTypeRecord="Single" AllowFieldMoving="No" AllowRecordFixing="No" RecordSelectorLocation="None"/>
</dp:XamDataGrid.FieldLayoutSettings>
<dp:XamDataGrid.FieldSettings>
<dp:FieldSettings AllowResize="False" CellClickAction="SelectRecord" LabelTextAlignment="Center" AllowEdit="False"/>
</dp:XamDataGrid.FieldSettings>
<dp:XamDataGrid.FieldLayouts>
<dp:FieldLayout Key="Details">
<dp:FieldLayout.Fields>
<dp:UnboundField Label="No" BindingPath="Number" Width="80"/>
<dp:UnboundField Label="Name" BindingPath="Name" Width="80"/>
<dp:UnboundField Label="Place" BindingPath="Place" Width="80"/>
</dp:FieldLayout.Fields>
</dp:FieldLayout>
</dp:XamDataGrid.FieldLayouts>
<dp:XamDataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Copy">
<MenuItem Header="Copy selected cells" Command="{Binding Path=CopySelectedCellsCommand}" CommandParameter="{Binding ElementName=m_dsGrid, Path=SelectedItems.Cells}" ToolTip="Reload current column layout from database.">
</MenuItem>
</ContextMenu>
</dp:XamDataGrid.ContextMenu>
</dp:XamDataGrid>
Reply
Answers (
1
)
tabIndex for wpf component
How to delete extra space between row in WPF datagrid