Question

im using the WPFToolkit's DataGrid and im trying to get an edit button working, here is the column:

<my:DataGridTemplateColumn>
                    <my:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock>
                                <Hyperlink   Command="{Binding EditVenueCommand}" >Edit</Hyperlink>


                            </TextBlock>
                        </DataTemplate>
                    </my:DataGridTemplateColumn.CellTemplate>
                </my:DataGridTemplateColumn>

and i am getting the following error:

BindingExpression path error: 'EditVenueCommand' property not found on 'object' ''Venue' (HashCode=18626439)'. BindingExpression:Path=EditVenueCommand; DataItem='Venue' (HashCode=18626439); target element is 'Hyperlink' (HashCode=32883419); target property is 'Command' (type 'ICommand')

the EditVenueCommand is fireing perfectly when it is outside the grid.

also, the reason i am using a DataGridTemplateColumn instead of a DataGridHyperlinkColumn is because i couldnt get that to work either :(

Was it helpful?

Solution

What's happening in your code is that the binding is treating "EditVenueCommand" as a property that it should find on the datacontext of the data template.

You really shouldn't use a Binding to hook up a command anyway, just use specify the namespace+type+command field like so:

Command="myns:MyType.EditVenueCommand"

Where myns is mapped to your CLR namespace. For example:

<Window xmlns:myns="clr-namespace:MyNamespace;assembly=MyAssemblyName" ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top