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
34510
Increase zero tick mark's width
posted

When you have a xamBulletGraph that has a minimum set to some negative value, how would you be able to modify just the tick mark that represents the 0 position in the graph?

When you have the range on the bullet graph set to something like, -50 to 50, the 0 position is marked with a tick mark that extends across the entire width/height of the bullet graph.  Which direction it extends depends on the orientation chosen for the graph, whether it's vertical or horizontal.  You can use this to your advantage to determine when you are on the correct tick mark.

I used an EventSetter on the tick mark style that handled the BulletGraphTickMark.Loaded event.  This event is fired whenever a new tick mark is created so we can use this to modify the width of the zero tick mark.  Assuming the graph orientation is set to horizontal, inside the Loaded event I check if the tick mark's height is equal to the height of the canvas it's contained within.  If it is that means this is the zero tick mark.  Here I set the width to what I want and store some initial values for later use in the LayoutUpdated event.

Now if you stop here you will notice that the width has been set but the tick mark now looks off center.  It needs to be repositioned to compensate for the change in size so inside the LayoutUpdated event for the tick mark I run some code to change the Canvas.Left position based on how much I changed the tick mark's width.

I've attached a sample application which demonstrates this.

xamBulletGraph-94579.zip