I want to bind AllowAddNew and AllowDelete in the FieldLayout Settings because their true/false values will depend on some values, say AllowEditData in the VM.
Any suggestions?
Hello InfraNewbie,
Unfortunately, it is not currently possible to 'directly' bind to a path in your ViewModel from the FieldLayoutSettings object. This is because the FieldLayoutSettings element does not derive from FrameworkElement and so does not expose a DataContext property, and so a direct Binding path will not work here - you will need a source.
The best recommendation I can make in this case is to bring your ViewModel into your XAML as a keyed resource. In doing so, you can set up a binding like the following, where "AllowAddNew" is a bool property on the ViewModel, which has a key of "VM" in this case:
AllowAddNew="{Binding Source={StaticResource VM} Path=AllowAddNew}"
I have attached a sample project to demonstrate the above. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
This approach does not work for me since I cannot set keyed resource for my ViewModel as it does not have a default constructor. As a matter of fact, its construction requires many parameters.
<local:ViewModel x:Key="VM"/