Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
xamColorPicker does not handle when user clicks outside of the control
posted

We are using XamColorPicker and need to know whether or not a user clicked on a color to close the color picker control.   We have the following setup:

- A color picker on a WPF window
- SelectedColor is bound to a property
- IsDropDownOpen bound to a property
- An event handler for DropDownClosing
- An event handler for DropDownClosed

- A change in the selected color in the color picker should change the background color of the WPF window.  A hover over a color in the color picker should not change the color of the background of the WPF window.

How can we handle the following cases?
1. Drop down the control and close it again using the drop down button without hovering over any color or clicking on any color
     We want to take no action

2. Drop down the control, hover over one or more colors, then click outside of the control to close the control.  The user would not click on to select any of the colors.
      We want to take no action and to not update anything based on the update to the property SelectedColor is bound to

3. Drop down the control, hover over one or more colors, then click on a color to close the control
      We want to update the WPF window's background color only one time with the final color clicked on by the user

How can we handle the case where the control is closed and the user did not select a color and the other case where the user selected a color.

Handling just the control is closed event or when the IsDropDownOpen property is set to false does not work.

Please add a Boolean property to the control indicating whether or not the user clicked on a color to select it.  This property would be set to false when the control is opened and set to true along with updating the selected color only after the user selects a color.   

This would let us handle a color selection by binding to the IsDropDown open property and in its set method using this logic,

private System.Windows.Media.Color lastSelectedColor;

private Boolean b;

public property bool IsColorPickerDropDownOpen

{

get { return b; }

set

  {

    if (value == true)

        lastSelectedColor = colorPickerControl.SelectedColor;

    else

       if (colorPickerControl.HasUserSelectedColor == true) && (colorPickerControl.SelectedColor != lastSelectedColor)

           {

             //handle color changed - newly selected color is colorPickerControl.SelectedColor

           }

      this.b = value

      OnPropertyChanged("IsColorPickerDropDownOpen");

  }

}

This is a different variant of this earlier question: http://ko.infragistics.com/community/forums/t/64357.aspx

This should be simple to use and not require adding dispatcher calls, retemplating, etc.

The control as it is works to update the last hovered over color instead of the selected one.

Parents
No Data
Reply
  • 815
    posted

    We need this color updated only if the user clicks on a color to select it because it will be eventually used to re-color the vertices of a 3D object having ~500,000 vertices.  Recomputing the colors of the vertices involves multiple computation steps and is non-trivial to compute.

    The 3D object rendered has a varying color based on the user selected color and a variance selected by another control on the WPF window.

Children
  • 138253
    Offline posted in reply to C

    Hello,

    Currently this is the designed behavior of XamColorPicker and if you want it to work differently without using any additional code, you can suggest new product idea for future versions (or vote for existing ones) at http://ideas.infragistics.com.

    There are many benefits to submitting an product idea:

    -          Direct communication with our product management team regarding your product idea.

    -          Notifications whenever new information regarding your idea becomes available.

    -          Ability to vote on your favorite product ideas to let us know which ones are the most important to you.  You will have ten votes for this and can change which ideas you are voting for at any time.

    -          Allow you to shape the future of our products by requesting new controls and products altogether.

    -          You and other developers can discuss existing product ideas with members of our Product Management team.

    Steps to create your idea:               

    1. Log into the Infragistics Product Idea site at http://ideas.infragistics.com (creating a new login if needed).
    2. Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
    3. Add your product idea and be sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!

    The Product Idea site puts you in the driver’s seat and allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.

    Thank you for contacting Infragistics.