As with support for parameterized constructor, this is most useful for existing classes that are not databinding-friendly and can’t be changed. For your own types, you might as well expose potential datasources as properties. But note that the photos collection exposed a method call ‘GetFolderName’, that returned a string representing the folder containing all the current items. You could expose this method as a datasource as follows.
[XAML}
<ObjctDataProvider x:Key='dataProvider' ObjectType='{x:Type Local:Photos}' MethodName='GetFolderName'/>
If the parameters need to be passed to the method, you can use ObjectDataProvider’s ‘MethodParameters’ property ( which works just like it’s ConstructorParameter property).
To Bind this method, simply bind it to the entire ObjectDataProvider.
[XAML]
<TextBlock Text='{Binding source={StaticResource dataProvider}}'/>
Specifying the path in this case would apply to the instance returned by the method.
Share with