Hi, I'm making some tests to see if I can use the XamTreeMap for one of my projects.
From what I've seen in the samples and the documentation, I have the possibility to ask the
control to change the color of a tile inside the tree based on the value displayed and this is a nice thing.
I've also seen that I can decide the color schema of the nodes for each node type (class) used.
Unfortunately I haven't found if there is a way to decide which color schema a tile have to use based on a property of said class.
I try to explain better.
I have a Class, named Company that is the first level node, the class have a value (Total) that is used as ValuePath in the node binder.
Company has an ItemsSourcePath (Amounts) that is a collection of Amount classes. Each amount class has a Node Binder that uses a field (Total) as valuepath.
The ValueMappers allow me to decide a color mapper for the Company class and a Color Mapper for the Amount class and this can be useful in some cases.
Unfortunately, my Amount classes are some of Type "INCOME" and some of type "OUTCOME" and it would be nice to paint the Income tiles in shades of Green based on the Total value and paint the Outcome tiles in shades of red/yellow based on the Total Value of the same.
After all this writing the question is:
can I set a different color schema for the tiles of a certain class based on the value assumed by a property in said class?
I hope I've been clear.
Sabrina
Hi Sabrina,
Definitely, although the custom mapper will need to figure out what color to apply. I attached a sample I had made in the past which used a LinearGradientBrush to calculate what color to apply to a particular node that fell between a specific range. The important methods to look at are the SetNodeColor and GetColorAtPoint methods.
Hi, the second case is my case, I've followed your link and I've been able to build a Custom Mapper class to paint Red or Green my squares.
Now I've been asked if as it is with the color mapper instead of a single color (Green in example), it is possible to create a Class with the From and To colors so that the value of the INCOME is darker or lighter based on the Income value.
Is there a way to create a custom mapper made this way?
Thank you in advance
Can you clarify about your INCOME and OUTCOME types? Does your Amount class contain a Type property with either INCOME or OUTCOME set? Or is there a new class named INCOME that derives from Amount? If you have a new class called INCOME then you should be able to color the tiles differently based on the class type. Take a look at my attached sample.
If your INCOME and OUTCOME types are defined as a property inside the Amount class then the ColorMapper feature isn't going to help. It cannot perform conditional coloring based on a particular type property that isn't the ValuePath. For this a custom mapper might be a better option. http://help.infragistics.com/doc/WPF/2015.1/CLR4.0/?page=xamTreemap_Custom_Value_Mappers.html