I have a Dictionary<Tuple<SomeEnum, double, string>, double>
that I'm trying to bind to in Xamarin. I'm just trying to bind the value (the double) to a label, nothing terribly fancy. The problem I'm having is that I can't figure out the path syntax to bind to a Tuple key. I know that with a Dictionary<string, double>
I would just let Path="[" + keyString + "]"
, for example, but I can't figure out what to do if I want to use a Tuple as the key. Even Microsoft's page on data binding path syntax in C# doesn't seem to explicitly handle this case, although it does note that
Inside indexers you can have multiple indexer parameters separated by commas (,). The type of each parameter can be specified with parentheses. For example, you can have
Path="[(sys:Int32)42,(sys:Int32)24]"
, where sys is mapped to the System namespace.
Now, I'd assume that this holds for single indexer objects too. So in my dictionary case, I suppose I would have something like Path="[(sys:Tuple<SomeEnum, sys:double, sys:string>)???]"
, but I'm not sure what goes where ???
is. And I'm not sure if I'd need a namespace before SomeEnum
. And finally, I can't seem to find any more detailed documentation. So I'll take help on any of these fronts.
Ultimately, I fear I may have to just give up, switch to a Dictionary<string, double>
, and let the string be the .ToString()
concatenation of the types in the Tuple, e.g. by letting each key be string key = SomeEnum.SomeValue + "," + someDouble + "," + someString
, but I'd really just prefer to do this correctly. I'm open to changing the Tuple to another non-string type if that helps though. Perhaps some other immutable type? I'm not terribly proficient with C# data binding beyond the basics, so any help or ideas are greatly appreciated.