Prob w/ BarExtent in Style (Setter) for CircularGauge

Gauge for WPF Forum

Posted 14 years ago by Marc Cygnus - Software Developer, Fire Em Up
Avatar
I have an app with several CircularGauge instances; I've defined a Style to help organize several common visual attributes. I'm now having a problem wherein some properties of a CircularScale are set properly by the Style but others (namely, BarExtent) are not.

Here's the style (simplified):

<Style x:Key="gaugeScale" TargetType="gauge:CircularScale" >
  <Setter Property="Radius" Value="82%" />
  <Setter Property="StartAngle" Value="190" />
  <Setter Property="SweepAngle" Value="160" />
  <Setter Property="BarExtent" Value="2%" />
  <Setter Property="Background" Value="#500000ff" />
</Style>
Here's an instance of a CircularGauge (again, simplified):

  <gauge:CircularGauge Background="Black" ...>
    <gauge:CircularGauge.Scales>
      <gauge:CircularScale Style="{StaticResource gaugeScale}">
      ...
      </gauge:CircularScale>
    </gauge:CircularGauge.Scales>
  </gauge:CircularGauge>
(There are, of course, ticks and a needle defined...)

The Style properly applies all properties correctly except for BarExtent. I can verify this by editing the values in the Style and watching the designer reflect the changes.

If I add an explicit BarExtent setting in the gauge:CircularScale element, that works.

At first, I thought it could be some bug or issue relating to the fact that BarExtent is not defined by CircularGauge but rather is inherited from ScaleBase, but besides the fact that that shouldn't matter, the Background property is also inherited from ScaleBase, and that works fine in the Style.

Please help! If need be, I could generate a small sample application that reproduces the issue, but I'm under a terrible timeline here, and I'm hoping that there's a simple explanation for the issue (given my schedule, I'd far rather hear "you're just an idiot - you forgot X" over "hmm, looks like a bug". ;-)

Thanks!

-Cygnus

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Cygnus,

The CircularScale constructor explicits sets the BarExtent, so your Style cannot be used to set. As the explicit value will take precedence over the Style Setter. This MSDN article describes the precedence order.

We need to explicitly set that property, so that it is properly inheirted down the visual tree.

[Modified at 10/16/2009 08:54 AM]


Actipro Software Support

Posted 14 years ago by Marc Cygnus - Software Developer, Fire Em Up
Avatar
Understood - makes sense now. Thank you!
The latest build of this product (v24.1.1) was released 21 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.