This is a migrated thread and some comments may be shown as answers.

Problems in loading values in RadSlider

3 Answers 115 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Jithin
Top achievements
Rank 1
Jithin asked on 17 Apr 2013, 03:33 AM

Hi Telerik Teams,

Please help me on one issue with loading values slider in Slider. When i load the slider with DoubleCollection I get an error .The project is done in Visual studio 2008. I lost lots of time for troubleshooting.But i cant solve this error. Please help me. 

The error is "Specified element is already the logical child of another element. Disconnect it first. in using canvas".

I mention below  the code that  implemented in the project for loading the Slider. 
----------------------------------------------------------------------------------------------------------------------------------------------

            ParentCanvas = New Canvas()
            ParentCanvas.ClipToBounds = True
            ParentCanvas.Width = 1200
            ParentCanvas.Height = 800
           
            Dim ValText As String
            Dim Valcode As Integer
            Dim tickcollection As New DoubleCollection()
            Dim canvas30 As New Canvas()
            If canvas30 IsNot Nothing Then
                canvas30.Children.Remove(RadSlider1)
            End If
            For i As Integer = 0 To alItemSource.Count
                Dim pInfo As TWBS.UI.B1.DashBoards.PlotInfo = alItemSource(i)
                ValText = pInfo.LegendLabel
                Dim dictionary As New Dictionary(Of String, Integer)
                dictionary.Add(ValText, i)
                Valcode = dictionary.Item(ValText)
                tickcollection.Add(Valcode)
                RadSlider1.Ticks = tickcollection
                RadSlider1.TickPlacement = Telerik.Windows.Controls.TickPlacement.BottomRight

                canvas30.Children.Add(RadSlider1)
                ParentCanvas.Children.Add(canvas30)
            Next
The Bolded code is the place where i get the error.Its urgent.please help me.......

3 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 19 Apr 2013, 02:11 PM
Hello Gopal,

I already answered to this question in your ticket but I will post the same answer here so others from the community will be able to see the answer.



I am not sure of your implementation and more specific I am not sure if your RadSlider1 element is defined in your XAML. I suppose that the issue is caused by the fact that you try to add the RadSlider1 control twice in the visual tree (which is not allowed). In order to add this control to the children collection of the canvas30 element you will first have to remove the RadSlider1 from the children collection of its parent (the element where you have defined it in XAML). Another approach is to define the RadSlider1 control in code behind only.

Regarding your requirement to visualize strings instead of numbers as ticks in the RadSlider control, you can use the TickTemplate property. Further more you can define a TextBlock which will display the string. Please note that the RadSlider accepts only DoubleCollection as its TickCollection. This is why you will have to use a custom converter and convert the double value into string. This approach is implemented in the attached project. Please take a look at it and let me know if it works for you.

All the best,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Jithin
Top achievements
Rank 1
answered on 20 Jan 2014, 08:27 AM

Hi Telerik Team,

Thanks for your help. In my project the chart will be load through grouping and slider is also with that chart. In that session the value of slider will be according to grouping of chart. At that time the converting code ( using Ivalue converter) will be fired. But after changing the slider value the convert function cant fired. 
0
Pavel R. Pavlov
Telerik team
answered on 22 Jan 2014, 04:40 PM
Hello Jithin,

I am not sure that I understand your scenario. Could you please elaborate more on your current implementation? Do you need to update the TickTemplate whenever the Value of the RadSlider is changed? This means that, whenever users slide the control, the corresponding template will be reapplied. Hence, the performance of the control will be greatly reduced. This does not seem like a valid scenario to me.

I guess that you change some other property - not the Value of the control. Please provide us with more detailed information about your scenario and we will try to figure our your issue.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Slider
Asked by
Jithin
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Jithin
Top achievements
Rank 1
Share this question
or