1

Looking for advice and elegant solution extracting properties and values into any convenient data structure.

Text="{Binding Path=SelectedValue,Mode=TwoWay}"

Solution is to having something sort of:

 List<string1, string2> where string1=Path, string2=SelectedValue

EDIT:

is it possible to make it GENERIC, to understand both ways current one and:

Command="{Binding ExecuteSearchCommand}
Wild Goat
  • 3,509
  • 12
  • 46
  • 87
  • you want to dynamically generate bindings based on a list of paths? – mmix Feb 23 '12 at 12:09
  • 1
    This screams "Regular expressions" – m0skit0 Feb 23 '12 at 12:09
  • This looks like a [XAML binding](http://msdn.microsoft.com/en-us/library/ms752300.aspx). Is it? If so, do you need to be able to parse the whole possible set of values or just the explicit example you give? – Christian.K Feb 23 '12 at 12:22

2 Answers2

3

Use:

var result = Regex.Matches(input, @"(\w+)=(\w+)").Cast<Match>()
    .Select(m => new 
        { 
            Property = m.Groups[1].Value, 
            Value = m.Groups[2].Value 
        });
Kirill Polishchuk
  • 54,804
  • 11
  • 122
  • 125
0

If you have an option to reformat your string slightly so it matches the JSON spec (i.e. replace your = with :, then you could use one of the following techniques):

Parsing JSON using Json.net

Parse JSON in C#

Community
  • 1
  • 1
Paddy
  • 33,309
  • 15
  • 79
  • 114