Rev | Line | |
---|
[4311] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Windows.Data;
|
---|
| 6 | using System.Windows;
|
---|
| 7 | using System.Collections;
|
---|
| 8 | using System.Text.RegularExpressions;
|
---|
| 9 |
|
---|
| 10 | namespace HeuristicLab.OKB.Cockpit.Query {
|
---|
| 11 | public class ListFormatter : IValueConverter {
|
---|
| 12 |
|
---|
| 13 | private Regex separator = new Regex(@"\s*,\s*");
|
---|
| 14 | public Regex Separator {
|
---|
| 15 | get {
|
---|
| 16 | return separator;
|
---|
| 17 | }
|
---|
| 18 | set {
|
---|
| 19 | separator = value;
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
---|
| 24 | IList lst = value as IList;
|
---|
| 25 | if (lst == null)
|
---|
| 26 | return value;
|
---|
| 27 | return string.Join(", ", lst.Cast<object>().Select(v => v.ToString()).ToArray());
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
|
---|
| 31 | string s = value as string;
|
---|
| 32 | if (string.IsNullOrEmpty(s))
|
---|
| 33 | return null;
|
---|
| 34 | return separator.Split((string)value).Cast<object>().ToList();
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.