You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
If you look at the implementation of this method, you'll notice that it breaks if the type name starts with "Xamarin.Forms":
internal static (BindableProperty, BindableProperty) GetForCommand(Type bindableObjectType)
{
(BindableProperty, BindableProperty) commandAndParameterProperties;
do
{
string bindableObjectTypeName = bindableObjectType.FullName;
if (bindableObjectTypeDefaultCommandAndParameterProperties.TryGetValue(bindableObjectTypeName, out commandAndParameterProperties))
break;
if (bindableObjectTypeName.StartsWith("Xamarin.Forms.", StringComparison.Ordinal)) // <---- Here
break;
bindableObjectType = bindableObjectType.GetTypeInfo().BaseType;
} while (bindableObjectType != null);
return commandAndParameterProperties;
}
I do not understand the purpose of breaking here and in fact this actually means that a class such as ToolbarItem breaks when using BindCommand. This is because the command and command parameter properties are actually registered for its base class MenuItem. If this line were removed, it would presumably work on the next pass in the loop. But because it is there, it throws the exception at the call site since the returned command property is null.
Furthermore, it's not possible to manually register the properties via RegisterCommand because these properties are already registered for MenuItem (where those properties are defined).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
If you look at the implementation of this method, you'll notice that it breaks if the type name starts with "Xamarin.Forms":
I do not understand the purpose of breaking here and in fact this actually means that a class such as
ToolbarItem
breaks when usingBindCommand
. This is because the command and command parameter properties are actually registered for its base classMenuItem
. If this line were removed, it would presumably work on the next pass in the loop. But because it is there, it throws the exception at the call site since the returned command property is null.Furthermore, it's not possible to manually register the properties via
RegisterCommand
because these properties are already registered forMenuItem
(where those properties are defined).Beta Was this translation helpful? Give feedback.
All reactions