Selected Color Binding

3 posts, 1 answers
  1. Ez
    Ez avatar
    5 posts
    Member since:
    Dec 2008

    Posted 10 May 2009 Link to this post

    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. Answer
    Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 11 May 2009 Link to this post

    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.
  3. DevCraft banner
  4. Ez
    Ez avatar
    5 posts
    Member since:
    Dec 2008

    Posted 13 May 2009 Link to this post

    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
Back to Top