Jump to content
Software FX Community

Customizing a CustomGridLine?


korthmat

Recommended Posts

Right now, I'm working on a graph that depicts sales as a percentage of expected sales.  One of the requirements is that I have to draw a line across the graph at 100% of expected sales.  A CustomGridLine would seem to be the solution.

The problems start when I try to customize the CustomGridLine.  In particular, the user should be able to specify:

  • the color of the line;
  • the text the line is labeled with;
  • the color of the text (which should match the color of the line); and
  • the alignment of the text (i.e., whether it appears on the left, on the right, or in the middle of the graph).

 So far, the only one of those three that I've been able to get is changing the text itself.

 This is the code I'm using right now:

<cfx:CustomGridLine Value="1"

Stroke="{Binding Source={StaticResource propertyBag}, Path=HundredPercentLineColor}"

StrokeThickness="2">

<cfx:CustomGridLine.Title>

<cfx:Title Content="{Binding Source={StaticResource propertyBag}, Path=HundredPercentLineText}"

Foreground="{Binding Source={StaticResource propertyBag}, Path=HundredPercentLineColor}"

TextAlignment="{Binding Source={StaticResource propertyBag}, Path=HundredPercentLineTextAlignment}" />

</cfx:CustomGridLine.Title>

</cfx:CustomGridLine>This causes VS2008 to complain that Stroke isn't a DP, and even if I take that out so I can work on something else, I still can't change the text from the left side to the right side of the chart.
Link to comment
Share on other sites

You can actually customize the gridline as you need but there are some issues that will prevent you from doing bindings to it, note that the following XAML will customize all the attributes you need

<

cfx:CustomGridLine Value="50" Stroke="Black" StrokeThickness="2">  <cfx:CustomGridLine.Title>   <cfx:Title Foreground="Red" HorizontalAlignment="Right">Expected Sales</cfx:Title>  </cfx:CustomGridLine.Title></cfx:CustomGridLine>

We will work on allowing these bindings to work on future builds.

Regards,

JuanC

Link to comment
Share on other sites

I don't normally reply to myself, but editing timed out.

I'd expect this to produce red text in the title:

 <cfx:CustomGridLine Value="50" Stroke="Black" StrokeThickness="2">

  <cfx:CustomGridLine.Title>

  <cfx:Title Foreground="Red" HorizontalAlignment="Right">Expected Sales</cfx:Title>

  </cfx:CustomGridLine.Title>

</cfx:CustomGridLine>

Unfortunately, it doesn't seem to do so.

Link to comment
Share on other sites

  • 4 months later...

Just following up on this one--

For the most part, this seems to work with RC1.  Right now, in a demo app, I've got this for my CustomGridLine declaration:

  <cfx:CustomGridLine Value="100" StrokeThickness="2"   Stroke="{Binding Source={StaticResource customGridLineSettings}, Path=LineBrush}">   <cfx:CustomGridLine.Title>   <cfx:Title Content="{Binding Source={StaticResource customGridLineSettings}, Path=Text}" Foreground="{Binding Source={StaticResource customGridLineSettings}, Path=LineBrush}" HorizontalAlignment="Left" />   </cfx:CustomGridLine.Title>   </cfx:CustomGridLine>

This allows me to change the stroke color, title content, and title color.  However, I also need to be able to bind against HorizontalAlignment--and as soon as I change HorizontalAlignment="Left" to HorizontalAlignment="{Binding Source={StaticResource customGridLineSettings}, Path=HorizontalAlignment}", I get an InvalidCastException ("Specified cast is not valid.")

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...