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

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

    I just built up quick sample. Please check if you are looking for the same. This is working at my end.

    • Xaml Code

      
          
          
          
          
          
      
      
    • Code Behind

      public class TextConverter : IValueConverter {
          #region IValueConverter Members
      
          public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
              string input = (string)value;
              char[] sep = {'/'};
              string[] iparray = input.Split (sep);
              int index = Int32.Parse((string)parameter);
      
              return iparray[index];
          }
      
          public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
              throw new NotImplementedException ();
          }
      
          #endregion
      }
      

    However, I couldn't understand the exact issue with ConvertBack method. Could you please elaborate on this?

提交回复
热议问题