Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackgroundColor not applied when binding to #47

Open
theincredibleschnigges opened this issue Oct 6, 2018 · 0 comments
Open

BackgroundColor not applied when binding to #47

theincredibleschnigges opened this issue Oct 6, 2018 · 0 comments

Comments

@theincredibleschnigges
Copy link

theincredibleschnigges commented Oct 6, 2018

Describe the bug
The BackgroundColor of the CircleButton does not get applied to the button when the button's still is bound to a derived style.

To Reproduce
I have the following style defined in my Application ResourceDictionary:

<Style x:Key="DashboardCircleButton" 
	 ApplyToDerivedTypes="True"
	 TargetType="btnCircle:CircleButton">
	<Setter Property="TextColor" Value="Black" />
	<Setter Property="HeightRequest" Value="70" />
	<Setter Property="WidthRequest" Value="70" />
	<Setter Property="BorderThickness" Value="3" />
	<Setter Property="BorderColor" Value="Black" />
	<Setter Property="HorizontalOptions" Value="Center" />
</Style>
<Style x:Key="DashboardCircleButtonOn" 
	   TargetType="btnCircle:CircleButton"
	   ApplyToDerivedTypes="True"
	   BasedOn="{StaticResource DashboardCircleButton}">
	<Setter Property="BackgroundColor" Value="LightGreen" />
	<Setter Property="TextColor" Value="LightGray" />
	<Setter Property="Text" Value="On" />
</Style>
<Style x:Key="DashboardCircleButtonOff" 
	   TargetType="btnCircle:CircleButton"
	   ApplyToDerivedTypes="True"
	   BasedOn="{StaticResource DashboardCircleButton}">
	<Setter Property="BackgroundColor" Value="OrangeRed" />
	<Setter Property="TextColor" Value="Black" />
	<Setter Property="Text" Value="Off" />
</Style>

In my ViewModel XAML, I have defined a CircleButton like this:

<btnCircle:CircleButton x:Name="GpsButton" Style="{StaticResource DashboardCircleButton}"
                                     HeightRequest="70" WidthRequest="70" />

In my code-behind file I am setting up a binding to the button's style like this (using ReactiveUI):

this.OneWayBind(ViewModel, x => x.IsGpsOn, x => x.GpsButton.Style, BoolToOnOffCircleButtonStyle);

The BoolToOnOffCircleButtonStyle returns either the DashboardCircleButtonOn or DashboardCircleButtonOff style, depending on the value of the property it is bound to.

Every property on the CircleButton is set correctly, except for the BackgroundColor (the button's background is white).

Expected behavior
The button's background should have the color which is defined in the style that is bound to it.
If I change the type of the button (and the targetType of the style accordingly) to a regular button, everything works as expected.

Please complete the following information:

  • Which version of the ButtonCircle do you use: 2.0.3
  • Which version of Xamarin.Forms do you use: 3.2.0.871581 (ReactiveUI: 9.0.1)
  • Which OS are you talking about: Multi-Platform solution testing UWP project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant