7

How can I bind to an attached property in Xamarin Forms XAML?

This doesn't work but it compiles and makes the most sense:

BindingContext="{x:Binding Source={x:Reference ControlName}, Path=(XMLNameSpace:ClassName.AttachedPropertyName)}"
The Pademelon
  • 835
  • 11
  • 29

1 Answers1

5

You can not use an attached BindableProperty as binding source, as there is no property backing up that BP in the Control you reference as Source. I can't think of any way making this work directly with bindings.

What will work is going through a ViewModel of some sort (can be defined as a StaticResource), and bind ControlName.AttachedProperty to a property of that VM (using OneWayToSource mode) and then bind to that property of that temporary VM.

Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85