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

Error getting colour from the Wpf RadColorPicker

1 Answer 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 02 Jan 2014, 12:26 PM
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

1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 07 Jan 2014, 12:54 PM
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
Tags
General Discussions
Asked by
Max
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or