How to Display ObservableCollection in a UserControl

后端 未结 4 1430
滥情空心
滥情空心 2021-01-15 13:48

I\'m new to WPF and I\'ve found some similar questions but can\'t quite figure out the last part. I have a ViewModel with an ObservableCollection that contains error messag

4条回答
  •  北海茫月
    2021-01-15 14:22

    Unless you have a great amount of messages a simple converter might be viable:

    
        
            
                
                    
                
            
        
    
    
    public class JoinStringsConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var strings = value as IEnumerable;
            return string.Join(Environment.NewLine, strings);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
    

提交回复
热议问题