Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Behavior<T> has a generic constraint on T of where T:BindableObject. However the Behaviors property only exists on VisualElement, not all bindable objects. You should not be allowed to define a Behavior for an element type that can't make use of it.
I ran into this while attempting to create a behavior for listview cells (Behavior<Cell>), only to discover that Cell does not inherit from VisualElement and therefore cannot have behaviors attached.
My preference is to move the Behaviors property to Element from VisualElement, or at least mirror the functionality as a special case for Cell. Otherwise, the only way for us to use Behaviors in a cell is to use our own ViewCell custom template, where we can attach them to the ViewCell.View.
But short of expanding the feature to include Cell (and perhaps other elements), the generic constraint on the Behavior<T> class should be restricted to disallow non-viable behavior definitions.
It is viable to consider library authors will allow now VisualElement BindableObject Behaviors. This is why the restriction is more lax.