Customizing the ValueTextStyle causes the text to be positioned at the center

Nov 28, 2010 at 11:19 AM

From the example in the first discussion, I tried to customize the style to use Cyan as the forecolor.

However this causes the text to jump to the center of the gauge... instead of its default position which is somewhere at the bottom-center of the gauge ?

Coordinator
Nov 28, 2010 at 6:19 PM

Hi Gishu,

Do you have some xaml?

Thanks,

Terry

Nov 30, 2010 at 5:05 AM

Comment the ValueTextStyle setter to contrast between the two states...

<WpfGauge:Gauge Value="{Binding RunsPerHour}" Grid.Row="0" Grid.Column="0"
                                        AutoScale="False" Width="120" Height="120"
                                        MinValue="0" MaxValue="80" MajorTickCount="8" MinorTickCount="4"
                                        ValueFormat=" {0} rph">
                            <WpfGauge:Gauge.ValueTextStyle>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Foreground" Value="Cyan"/>
                                </Style>
                            </WpfGauge:Gauge.ValueTextStyle>
                        </WpfGauge:Gauge>

Coordinator
Nov 30, 2010 at 12:00 PM

Gishu,

When you set the ValueTextStyle, you have to throw a setter in there for placement.  The following should do the trick:

        <WpfGauge:Gauge Value="{Binding RunsPerHour}" Grid.Row="0" Grid.Column="0"
                                        AutoScale="False" Width="120" Height="120"
                                        MinValue="0" MaxValue="80" MajorTickCount="8" MinorTickCount="4"
                                        ValueFormat=" {0} rph">
            <WpfGauge:Gauge.ValueTextStyle>
                <Style TargetType="TextBlock">
                    <Setter Property="Foreground" Value="Cyan"/>
                    <Setter Property="Margin" Value="0,65,0,0" />
                </Style>
            </WpfGauge:Gauge.ValueTextStyle>
        </WpfGauge:Gauge>

Dec 1, 2010 at 7:33 AM

Ok. The margin property.. I was looking for some VerticalAlignment like property but was unable to find one.

This works  but  I'd have to copy over everything from the default style - I'd like to keep all the styling but just change the font color. Is the default style named so that I can use the BasedOn attribute to override selected properties ?