if I have an object say called MyObject, which has a property called MyChild, which itself has a property called Name. How can I get the value of that Name property if all I have is a binding path (i.e. "MyChild.Name"), and a reference to MyObject?
MyObject
-MyChild
-Name
I am doing it this way. Please let me know if this is a terrible idea, as C# is just a side job for me so I am not an expert objectToAddTo is of type ItemsControl:
I found a way to do this, but it's quite ugly and probably not very fast... Basically, the idea is to create a binding with the given path and apply it to a property of a dependency object. That way, the binding does all the work of retrieving the value:
I developed a nuget package Pather.CSharp that does exactly what you need.
It contains a class
Resolver
that has aResolve
method which behaves like @ThomasLevesque'sGetValue
method.Example:
It even supports collection access via index or dictionary access via key.
Example paths for these are:
not sure what you want to do but and how (xaml or code) yet you can always name your object
an then use it in code
or in xaml