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

前端 未结 5 1543
醉梦人生
醉梦人生 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:48

    In this case, if you really want to be able to edit the constituents, you could represent your number by a more complex object which allows you to access its 4 constituent parts through an indexer. That way it's just a simple binding and the object that keeps the 4 parts is accessed and can piece together the whole number:

    public class MyNumber {
      public int this[int index] {
        get { /**/ } set { /**/ }
      }
      public string FullNumber { get { /**/ } }
    }
    
    
    

提交回复
热议问题