Checkbox background change on Mouse over

1 Answer 70 Views
Styling
Deltaohm
Top achievements
Rank 1
Iron
Deltaohm asked on 29 Jul 2021, 08:31 AM

Hi,

I use a standard Wpf Checkbox inside a RadPanelBarItem. I bind the background to a dynamic color and this works well, but when the mouse is over the box the background back to white, I would like that still remains of the assigned color.
Thank you in advance
Luigi

P.S:
Here the useful part of xaml (nothing in code behind)


<DataTemplate x:Key="PanelBarSorgentiTemplate">
			<StackPanel Orientation="Horizontal"  >				
				<CheckBox Margin="10 5 5 5" VerticalAlignment="Center"
						  IsChecked="{Binding IsChecked}"
						  Background="{Binding Color, Converter={StaticResource ColorToBrush}}"
						  
						  />
				<TextBlock Text="{Binding Name}"
						   VerticalAlignment="Center" />

			</StackPanel>
		</DataTemplate>
		
<t:RadPanelBarItem Header="{DynamicResource ResourceKey={x:Static l:ResourcesKeys.StatisticheVisualizzate}}"
							   ItemsSource="{Binding TabRisultati.StatisticheVisualizzate}"
							   ItemTemplate="{StaticResource PanelBarSorgentiTemplate}"
							   Visibility="{Binding IsTabStatisticaSelected, Converter={StaticResource BoolToVis}}"
							   IsExpanded="True"/>

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 02 Aug 2021, 09:22 AM

Hi Deltaohm,

Thank you for the provided code snippet.

Based on it, I've prepared a small sample project which demonstrates how to achieve the desired result. It involves using the properties of the ThemeHelper class and modifying the control template of the CheckBox control to remove unnecessary triggers.

Here's the modified definition of the CheckBox control for your reference:

                <CheckBox Margin="10 5 5 5" VerticalAlignment="Center"
						  IsChecked="{Binding IsChecked}"
                          Style="{StaticResource NoMouseOverCheckBoxStyle}"
						  Background="{Binding Color, Converter={StaticResource ColorToBrush}}"
                          helpers:ThemeHelper.MouseOverBrush="{Binding Color, Converter={StaticResource ColorToBrush}}"
                          helpers:ThemeHelper.FocusBrush="{Binding Color, Converter={StaticResource ColorToBrush}}"
                          helpers:ThemeHelper.CheckedBrush="{Binding Color, Converter={StaticResource ColorToBrush}}"
                          telerik:StyleManager.Theme="Fluent">
                </CheckBox>

Please note, however, that this solution is specific to the Fluent theme (used with the Xaml binaries) and if you're using other theme(s) you will need to edit the control template accordingly.

If that is the case, and you require further assistance on the matter, please specify the themes and theming approach you're using so that I can demonstrate a possible solution for your particular scenario.

Regards,
Dilyan Traykov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Styling
Asked by
Deltaohm
Top achievements
Rank 1
Iron
Answers by
Dilyan Traykov
Telerik team
Share this question
or