If i have a Button on the screen with Visual="Material" when i change BackgroundColor property of the button in code the change does nothing on iOS, this works if the button is Visual="Default", and works fine on Android for both.
The background colour should toggle/change every click
Nothing happens
Reproduced in TheLittleThingsPlayground by simply adding this to ButtonsPage.xaml.cs Constructor:
``` C#
Task.Run( async () =>
{
while( true )
{
if( testColorChange.BackgroundColor == Color.Black )
{
testColorChange.BackgroundColor = Color.Green;
}
else
{
testColorChange.BackgroundColor = Color.Black;
}
await Task.Delay( 1000 );
}
} );
```
and changing any button to have the x:Name="testColorChange"
has there been any update on this issue?
Replicated.
System Information
Visual Studio: 16.1.1
Xamarin.iOS and Xamarin.Mac SDK version: 12.10.0.153(750a879)
Xamarin.Forms version: 4.0.0.425677
Xamarin.Forms.Visual.Material version: 4.0.0.425677
Implementing a custom renderer solves this problem.
internal class CustomMaterialButtonRenderer : MaterialButtonRenderer
{
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == nameof(Element.BackgroundColor))
{
Control.BackgroundColor = Element.BackgroundColor.ToUIColor();
}
}
}
Happening in 4.2-nightly. I wonder if it's the material SemanticColorScheme check...wild guess. https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Material.iOS/MaterialButtonRenderer.cs#L149
for those wondering how to export the workaround custom renderer (@darshanio ) to override material renderer only:
[assembly: ExportRenderer(typeof(Button), typeof(CustomRenderers.iOS.CustomMaterialButtonRenderer), new[] { typeof(VisualMarker.MaterialVisual) })]
I don't like the idea of requiring to use a custom renderer for this, Is there an eta on official fix from Xamarin.Forms side?
HI all!
Any news on this?
Thank you!
@PureWeen, it has been a few months has there been any development on this issue?
Most helpful comment
Replicated.
System Information
Visual Studio: 16.1.1
Xamarin.iOS and Xamarin.Mac SDK version: 12.10.0.153(750a879)
Xamarin.Forms version: 4.0.0.425677
Xamarin.Forms.Visual.Material version: 4.0.0.425677
Implementing a custom renderer solves this problem.