Exemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, string culture)
        {
            string displayMemberPath = parameter as string;

            if (String.IsNullOrWhiteSpace(displayMemberPath) || value == null)
            {
                return(String.Empty);
            }

            PropertyInfo propertyInfo;

            return(string.Join(", ", (value as IEnumerable <object>).Select(item =>
            {
                if (displayMemberPath == ".")
                {
                    return item;
                }
                propertyInfo = DataControlHelper.GetPropertyInfo(item.GetType(), displayMemberPath);
                if (propertyInfo == null)
                {
                    return String.Empty;
                }
                return propertyInfo.GetValue(item, null);
            }).ToArray()));
        }
Exemplo n.º 2
0
 object GetSelectedValue(object item)
 {
     if (item == null)
     {
         return(null);
     }
     if (SelectedValuePath == ".")
     {
         return(item);
     }
     return(DataControlHelper.GetPropertyInfo(item.GetType(), SelectedValuePath)?.GetValue(item, null));
 }