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

MaterialDesignSwitchToggleButton background colour is hardcoded #1408

Closed
wwarby opened this issue Sep 7, 2019 · 4 comments
Closed

MaterialDesignSwitchToggleButton background colour is hardcoded #1408

wwarby opened this issue Sep 7, 2019 · 4 comments
Labels
enhancement good first issue Items are good for new contributors. Hacktoberfest Items are good for new contributors during hacktoberfest. https://hacktoberfest.digitalocean.com/ up-for-grabs
Milestone

Comments

@wwarby
Copy link

wwarby commented Sep 7, 2019

As best I can tell, the background colour on the "track" for the switch-style toggle button is hardcoded to Black. Since my app's background colour is close to black, this makes the default style of the switch toggle button unusable. I've tried to override the default style, so far without success - this is probably because I don't understand XAML style inheritance well enough to target the property correctly, but I wonder if perhaps it shouldn't be hardcoded to Black anyway, especially if the selected theme is Dark? What would be great is if it could just inherit the Background brush for the ToggleButton itself. This was my failed attempt at overriding:

  <Style x:Key="MaterialDesignSwitchToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource MaterialDesignSwitchToggleButton}">
    <Style.Resources>
      <Style TargetType="{x:Type Rectangle}">
        <Setter Property="Fill" Value="Red" />
      </Style>
    </Style.Resources>
  </Style>
@Keboo Keboo added this to the 3.0.0 milestone Sep 10, 2019
@Keboo
Copy link
Member

Keboo commented Sep 23, 2019

For this we should do the following:

  • Add a new attached property in ToggleButtonAssist called SwitchTrackBackground of type Brush. It should default to Black
  • Use this new attached property as the Fill for the rectangle on the MaterialDesignSwitchToggleButton
  • Update the demo app so one of the switches shows off changing this color.

@Keboo Keboo added enhancement good first issue Items are good for new contributors. Hacktoberfest Items are good for new contributors during hacktoberfest. https://hacktoberfest.digitalocean.com/ up-for-grabs labels Sep 23, 2019
@laxmy
Copy link
Contributor

laxmy commented Sep 26, 2019

Hi @Keboo ,
Can I pick this up?

@Keboo
Copy link
Member

Keboo commented Sep 26, 2019

@laxmy yes all yours.

laxmy added a commit to laxmy/MaterialDesignInXamlToolkit that referenced this issue Oct 9, 2019
@laxmy
Copy link
Contributor

laxmy commented Oct 9, 2019

Hi @Keboo ,
I've raised a PR. Please review

Keboo pushed a commit to laxmy/MaterialDesignInXamlToolkit that referenced this issue Oct 15, 2019
Keboo pushed a commit that referenced this issue Oct 15, 2019
* #1408: Adding Track Background to SwitchToggleButton

* Updating to have two brushes for the background

Updated demo to reflect change.
Fixing binding error on the off background color.
@Keboo Keboo closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue Items are good for new contributors. Hacktoberfest Items are good for new contributors during hacktoberfest. https://hacktoberfest.digitalocean.com/ up-for-grabs
Projects
None yet
Development

No branches or pull requests

3 participants