Problems in loading values in RadSlider

4 posts, 0 answers
  1. Jithin
    Jithin avatar
    2 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2013 Link to this post

    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
                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)
                    RadSlider1.Ticks = tickcollection
                    RadSlider1.TickPlacement = Telerik.Windows.Controls.TickPlacement.BottomRight

    The Bolded code is the place where i get the error.Its urgent.please help me.......

  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 19 Apr 2013 Link to this post

    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.

  3. Jithin
    Jithin avatar
    2 posts
    Member since:
    Apr 2013

    Posted 20 Jan 2014 Link to this post

    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. 
  4. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1237 posts

    Posted 22 Jan 2014 Link to this post

    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.

    Pavel R. Pavlov
    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 >>
Back to Top