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

Selected Color Binding

2 Answers 167 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Ez
Top achievements
Rank 1
Ez asked on 10 May 2009, 03:24 PM
I'd like to set the selectedColorProperty of the radColorPicker to be bound to a value.

I need the binding mode to be twoWay.

This is the code I am using:

 

var fg = new Binding("TextBlockForeground");

 

fg.Source = cStyles;

fg.Converter = cc;   (WHERE cc returns a SolidColorBrush.Color)

fg.Mode =

BindingMode.TwoWay;

 

cp.SetBinding(

RadColorPicker.SelectedColorProperty, fg);

When the color picker loads and when I select a color, the value that it is bound to updates correctly, however, the chosen color represented in the colorpicker's icon is not updated.

Is this a bug?

Thanks,
Ez

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Valentin.Stoychev
Telerik team
answered on 11 May 2009, 11:15 AM
Hi Ez,

We need some help in order to reproduce the problem. we tried with the following code and all seems to work just fine:
Code Behind:
        private Color p = Colors.Brown;  
        public Page()  
        {  
            InitializeComponent();  
 
            var fg = new Binding("TextBlockForeground");   
            fg.Source = this;  
            fg.Mode = BindingMode.TwoWay;  
            RadColorPicker1.SetBinding(RadColorPicker.SelectedColorProperty, fg);  
        }  
 
        public Color TextBlockForeground  
        {  
            get   
            {  
                return this.p;  
            }  
            set 
            {  
                this.p = value;  
            }  
        } 

XAML:
<UserControl x:Class="SilverlightApplication10.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   
             xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
        xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" 
    Width="400" Height="300">  
    <Grid x:Name="LayoutRoot" Background="White">  
            <telerikInput:RadColorPicker x:Name="RadColorPicker1"></telerikInput:RadColorPicker> 
                 
    </Grid> 
</UserControl> 



Regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ez
Top achievements
Rank 1
answered on 13 May 2009, 10:12 AM
It seems as if the issue was that I was using a converter to convert the "selectedColor" string into a Media.Color for the color picker.

I turned the converter off, and all works fine.

Thanks for your help.

Ez
Tags
ColorPicker
Asked by
Ez
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Ez
Top achievements
Rank 1
Share this question
or