I have a ToolBarItem
defined like
<ToolbarItem Order="Primary" Text="Next" Icon="next.png" IsEnabled="False" />
On iOS and UWP the icon is grayed out when the control is set to disabled. On Android the icon is showing the original color. If I remove the icon and use only text, then the text changes color as expected when the control is disabled.
<ContentPage.ToolbarItems>
<ToolbarItem Order="Primary" Icon="next.png" IsEnabled="False" />
<ToolbarItem Order="Primary" Icon="next.png" IsEnabled="True" />
<ToolbarItem Order="Primary" Text="Next" IsEnabled="False" />
<ToolbarItem Order="Primary" Text="Next" IsEnabled="True" />
</ContentPage.ToolbarItems>
I expect the icon to be rendered in a disabled state, as is the case on UWP and iOS.
Icon is rendered the same in both enabled and disabled state.
I personally classify this as a bug but it would be a functionality change as well. We'll need to discuss this with PM
Hi @jassmith, What's the status of Pull Request ? will it be fixed soon? we really need this please.
Hi @jassmith, how is it going after few months? Is there any inconvenience or difficulty in implementing it, or it's just a low priority? From company site this feature is really awaited because with the current implementation of the forms toolbar it's impossible to workaround this issue, without reimplementing completely the toolbar control.
Could you let us know if are you going to fix it in near future, or we should start to implement our own toolbar control?
Thanks,
I set up a custom control that removes the image from the toolbar item whenever the item is disabled, and adds it again whenever the item is enabled. I know my use case is very specific, but this really simple approach might be a useful workaround for some while the issue is not fixed.
public class DisableableToolbarItem : ToolbarItem
{
private FileImageSource _fileImageSource;
protected override void OnPropertyChanged(string propertyName)
{
if (propertyName == DisableableToolbarItem.IsEnabledProperty.PropertyName)
{
if (this.IsEnabled)
{
this.Icon = _fileImageSource;
}
else
{
_fileImageSource = Icon;
this.Icon = null;
}
}
base.OnPropertyChanged(propertyName);
}
}
You could even have 2 images that flip whenever the IsEnabled property changes, that wouldn't be difficult either.
Isn't this pull request #3773 already addressing this issue? It is already merged.
Just tested with the latest Xamarin.Forms and works as expected :)
Still reproduces on 4.2.0.709249, the IsEnabled property is ignored and the command is executing regardless of the value of IsEnabled.
Most helpful comment
I personally classify this as a bug but it would be a functionality change as well. We'll need to discuss this with PM