How to dynamically add a converter in code-behind

前端 未结 1 776
执笔经年
执笔经年 2021-02-14 21:28

I am Binding a Datagrid to dynamic data via IDictionary: http://www.scottlogic.co.uk/blog/colin/2009/04/binding-a-silverlight-datagrid-to-dynamic-data-via-idictionary/comment-pa

相关标签:
1条回答
  • 2021-02-14 21:42

    The converter is called after getting at the data through the property path. As there is no "Forename" property in Row, it does not work (you can see the Binding exception in the Output window).

    I solved it by changing the Binding definition to:

        Binding bind = new Binding();
        bind.Mode = BindingMode.OneWay;
    

    as you cannot have two-way binding without a path (the exception I got without the second line). Having no property path makes sense, on second thought, as we want to bind to the full Row object, not to one of its properties.

    Note: tested with VS 2008 SP1, WPF project.

    0 讨论(0)
提交回复
热议问题