RadSlider with multiple thumbs loses style information when using PRISM

1 Answer 76 Views
Slider
Joshua
Top achievements
Rank 1
Joshua asked on 11 Aug 2023, 09:33 AM

I'm using the RadSlider control to display a RangeSliderThumb (to define a range of values) and a regular SliderThumb (to define one value within that range). To be able to differentiate the regular SliderThumb i applied some style to it.

We are using PRISM and i noticed the style of the regular SliderThumb is reset when i navigate to the page a second time. None of the other styles are affected by navigating to the page multiple times.

I've attached a project with a stripped down version of my problem. Pressing the buttons navigates to the respective pages.

Screenshot after first navigation (style is applied as expected):

Screenshot after second navigation (style of regular SliderThumb is reset):

 

Any ideas on how to fix that behavior?

 

Greetings

Josh

Joe
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 11 Aug 2023, 03:25 PM

I don't work for Telerik or anything so take this with a grain of salt, but isn't the "SelectionMiddleThumbStyle" property of RadSlider what you want?

https://docs.telerik.com/devtools/wpf/knowledge-base/kb-slider-style-middle-thumb-style-manager
Joshua
Top achievements
Rank 1
commented on 21 Aug 2023, 07:32 AM

I think the "SelectionMiddleThumbStyle" only applies to the middle part (the yellow bar in the screenshots). In my use case i need both the range selection and another single slider that can move freely inside the selected range.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 16 Aug 2023, 08:16 AM

Hello Joshua,

To resolve the issue, you can subscribe to the Loaded event of the SliderThumb element and manually sync its Style with the ThumbStyle. For example:

  <telerik:SliderThumb InteractionMode="Push"
                                    Value="25" 
                                    Loaded="SliderThumb_Loaded">

 

private void SliderThumb_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
	var thumb = (SliderThumb)sender;
	if (thumb.ThumbStyle != null)
	{
		thumb.SetCurrentValue(SliderThumb.StyleProperty, thumb.ThumbStyle);
	}        
}

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Joshua
Top achievements
Rank 1
commented on 21 Aug 2023, 07:35 AM

This solution works, though i try to prevent to use code behind where possible.

But based on your suggestion i tried around and figured out that if i set both the "Style" and the "ThumbStyle" of the SliderThumb, the desired style is applied as expected.

Martin Ivanov
Telerik team
commented on 22 Aug 2023, 09:31 AM

I am glad to hear that you've managed to find a solution. Also, thank you for sharing it.
Tags
Slider
Asked by
Joshua
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or