WPF textblock binding with List

后端 未结 4 1824
-上瘾入骨i
-上瘾入骨i 2020-11-29 08:48

does anyone know if there is a simple way to bind a textblock to a List. What I\'ve done so far is create a listview and bind it to the List and then I have a template withi

4条回答
  •  感动是毒
    2020-11-29 09:32

    For concat collection of objects :

        /// Convertisseur pour concaténer des objets.
    [ValueConversion(typeof(IEnumerable), typeof(object))]
    public class ConvListToString : IValueConverter {
        /// Convertisseur pour le Get.
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            return String.Join(", ", ((IEnumerable)value).ToArray());
        }
        /// Convertisseur inverse, pour le Set (Binding).
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
            throw new NotImplementedException();
        }
    }
    
    
    

    Juste think to overide the ToString() of your object.

    提交回复
    热议问题