Restrict ColorMode

4 posts, 0 answers
  1. Flemming Rosenbrandt
    Flemming Rosenbrandt avatar
    119 posts
    Member since:
    Mar 2006

    Posted 20 Mar 2014 Link to this post

    How do I restrict the ColorMode to RGB only?

    /Flemming Rosenbrandt

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 25 Mar 2014 Link to this post

    Hi Flemming,

    There is no "out of the box" way to achieve this requirement. You can edit the default Style of the RadColorEditor. In it , there is a RadComboBox bound to collection of ColorModeWrapper classes:
    xmlns:colorMode="clr-namespace:Telerik.Windows.Controls.ColorEditor.Mode"

    <colorMode:ColorModeCollection x:Key="ColorModeCollection" />
     
    <telerikInput:RadComboBox IsEditable="True" telerik:StyleManager.Theme="{StaticResource Theme}" IsReadOnly="True"
                                                              ItemsSource="{Binding Source={StaticResource ColorModeCollection}}"
                                                              SelectedIndex="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ColorMode, Mode=TwoWay, Converter={StaticResource EnumConverter}}">
    And the ColorModeCollection is defined as follows:
    /// <summary>
    /// Represents a collection of enum wrappers.
    /// </summary>
    public class ColorModeCollection : List<ColorModeWrapper>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ColorModeCollection"/> class.
        /// </summary>
        public ColorModeCollection()
        {
            this.Add(new ColorModeWrapper() { EnumValue = (int)ColorMode.CMYK });
            this.Add(new ColorModeWrapper() { EnumValue = (int)ColorMode.HLS });
            this.Add(new ColorModeWrapper() { EnumValue = (int)ColorMode.HSV });
            this.Add(new ColorModeWrapper() { EnumValue = (int)ColorMode.RGB });
        }
    }
    What can you do is to create a new ColorModeCollection class with RGB ColorModeWrapper only and bind it to the mentioned ComboBox in XAML.

    Regards,
    Petar Mladenov
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. DevCraft banner
  4. Flemming Rosenbrandt
    Flemming Rosenbrandt avatar
    119 posts
    Member since:
    Mar 2006

    Posted 25 Mar 2014 in reply to Petar Mladenov Link to this post

    Thank you for the answer.

    If I am to edit the style of the RadColorEditor anyway – I could just hide the ComboBox?

    I would have expected this feature to be a natural part of the ActiveSections property?

    /Flemming Rosenbrandt

  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 26 Mar 2014 Link to this post

    Hello Flemming,

    Yes you can edit the Style of the RadColorEditor and set the Visibility of this RadComboBox. 
    Actually you can submit a feature requests for our controls in our new Feedback Portal. In this case you can describe that you need a property (for example ColorModeComboVisbility) or a way to extend the ActiveSections.

    Regards,
    Petar Mladenov
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top