Hi, i would like to have a task highlighted when i select its row; i was thinkin about changing the row color but i don't know how to do it.
Can i have an example?
Thanks, Fabrizio
Hi Fabrizio,
I have attached a sample application that demonstrates how you might change the row color based on a property in your task. The property in this example is called IsMarked and when true it will set the background of the row to red, regardless of whether it is selected or not.
I had to retemplate the cells in order to adjust how the cell color changes based on state. There are a number of states that can change the cell color such as whether it is on an alternating row, is selected, is hovered, etc. The way these cells change their color is by using visual states in order to change the color of Rectangle elements in the cell. These Rectangle elements are overlapped on top of each other so it's possible for some states to override the appearance of other states. In order to make an "IsMarked" state I added a new Rectangle elements and added a DataTrigger to hide or show it based on the value of the IsMarked property. You can adjust the priority of these states by adjusting how the Rectangle elements are ordered relative to each other.
Let me know if you have any questions.
Ah I think I see what you mean. So the row isn't technically selected in the way the XamGantt thinks of selection by default but you want to give it the appearance of being selected based on a property in your task. This sounds like a job for styling. I will write up a sample and share it here when finished.
Hi Rob,
it surely does, but how can i set a row as 'selected' in function of a Project attribute?
I.e. all the tasks having 'IsMarked' property = true have to be highlighted automatically (binding two-way the property).
Fabrizio
Doesn't the row color already change in the XamGantt when you select a row? When I say row I am referring to the DataGrid element on the left hand side of the XamGantt control. Is this not what you mean?
I attached an image of what I mean. In the image, the "Collect Feedback" task is highlighted because I selected the row with the mouse by clicking the row selector area in the left most grid column.