Get the Source value in ConvertBack() method for IValueConverter implementation in WPF binding

前端 未结 5 1537
醉梦人生
醉梦人生 2021-01-02 12:05

I am binding a dependency property to textboxex in WPF. The property is a string that has some values separated by \'/\' (example: \"1/2/3/4\" ). I need to bind individual v

5条回答
  •  攒了一身酷
    2021-01-02 12:44

    In most cases, you can safely make ConvertBack just throw NotImplementedException.

    Indeed, you just haven't got enough information to recreate the source value from its part!

    If you really need the back conversion (e.g., if you use two-direction binding), I would split the property into 3 strings in the view model (the class used in DataContext), and bind to them separately.

提交回复
热议问题