Error getting colour from the Wpf RadColorPicker

2 posts, 0 answers
  1. Max
    Max avatar
    17 posts
    Member since:
    May 2012

    Posted 02 Jan 2014 Link to this post

    Framework version used: 2013.2.1210.0

    so we have a class that inherits from the RadColorPicker as per below
    public class VisualColourPicker : RadColorPicker
    {
    }
    which we use to get to the VisualColourPicker.SelectedColor property to find the ...well the selected colour.
    This however throws an error at the moment with an Element Not found exception using the FindExpression [name 'Exact' LeftButton]
    using snoop I have determined that the button that is in fact trying to be located is called "ButtonPart". So i have written my Property code as follows to get around this on my class I mentioned above...
    public ArtOfTest.WebAii.Controls.Xaml.Wpf.Color CustomSelectedColor
    {
        get
        {
            var but = this.Find.ByName<ArtOfTest.WebAii.Controls.Xaml.Wpf.Button>("ButtonPart");
            var rec = but.Find.ByType<ArtOfTest.WebAii.Silverlight.UI.Rectangle>();
            return (rec.Fill as ArtOfTest.WebAii.Silverlight.UI.SolidColorBrush).Color;
        }
    }
    This however now gives me. An error of "Unable to cast object of type 'ArtOfTest.WebAii.Controls.Xaml.Wpf.SolidColorBrush' to type 'ArtOfTest.WebAii.Silverlight.UI.Brush'." So I had to change my property code above to the following to get the selected colour.
    var but = this.Find.ByName<ArtOfTest.WebAii.Controls.Xaml.Wpf.Button>("ButtonPart");
    var rec = but.Find.ByType<ArtOfTest.WebAii.Silverlight.UI.Rectangle>();
    var fill = (ArtOfTest.WebAii.Controls.Xaml.Wpf.SolidColorBrush)rec.GetProperty(new ArtOfTest.WebAii.Silverlight.AutomationProperty("Fill", typeof(ArtOfTest.WebAii.Controls.Xaml.Wpf.SolidColorBrush)));
    return fill.Color;
    Is there a reason why 1: simply VisualColourPicker.SelectedColor does not work out of the box in that its looking for some "LeftButton"
    2: When I try and get the colour with myown property that the out of box Fill property then fails in an internal cast. Thanks
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 07 Jan 2014 Link to this post

    Hello Max,

    Thank you for contacting us.

    Unfortunately I cannot say exactly why it is looking for "leftButton" without seeing the application. If it is possible grant us access to your application and we will try to investigate the problem.

    Regarding the casting error, this is expected behavior, you cannot cast it directly. Your final code seems correct.

    Hope to hear from you soon.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top