开发者

Command in a WPFToolkit DataGridTemplateColumn not working

开发者 https://www.devze.com 2022-12-08 22:50 出处:网络
im using the WPFToolkit\'s DataGrid and im trying to get an edit button working, here is the column: <my:DataGridTemplateColumn>

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)'. BindingExpressi开发者_如何学Pythonon: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 :(


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" ...
0

精彩评论

暂无评论...
验证码 换一张
取 消