How to get the WpfGauge to scale better ?

Nov 28, 2010 at 12:17 PM

http://db.tt/bANDzrF

The above is a shortened link for 2 snapshots.

On the left hand side, I have the gauge inside a Viewbox.

On the right hand side, I have the gauge set with hard coded height and width values.

I'd like the gauge to scale according to the availablespace (I would set a MinHeight and MinWidth) - take available of extra space if any. In the snapshot, the area available for the gauges is the same, however the LHS doesnt seem to be utilizing the available space effectively.  I couldn't find any way of specifying the size of the inner and outer ellipses.

Coordinator
Nov 28, 2010 at 7:17 PM

Hi Gishu,

Do you have the xaml for both of the screenshots above?

Thanks,

Terry

Nov 30, 2010 at 5:53 AM

Sure Terry, here it is.

This is the RHS. For the LHS, Uncomment the Viewbox and remove the Gauge.Width and Gauge.Height setters.

 

<!--<Viewbox x:Name="gaugeHome"  Grid.Row="1" Grid.Column="0" Stretch="Uniform">-->
                        <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.TickLabelStyle> <!--snipped--></WpfGauge:Gauge.TickLabelStyle>
                            </WpfGauge:Gauge>
                        <!--</Viewbox>-->

Coordinator
Nov 30, 2010 at 12:56 PM

I am having trouble duplicating this issue.  Could you post the exact xaml that you are using for the secong gauge?

Thanks,

Terry

Dec 4, 2010 at 3:28 PM
Edited Dec 4, 2010 at 3:29 PM

Here's a complete solution which depicts the issue - http://db.tt/v6r45a4

Also there seem to some data binding errors with the wpfGauge - check the output tab

Coordinator
Dec 5, 2010 at 8:19 PM

Hi Gishu,

Thanks for the code to reproduce the issue.  I am still looking at the scaling of the Gauge.  As far as the databinding issue, it looks like your code is doing some strange things.  When you assign a new data source by clicking on the button, you get two binding errors:

System.Windows.Data Error: 40 : BindingExpression path error: 'LeftProp' property not found on 'object' ''MainViewModel' (HashCode=38308053)'. BindingExpression:Path=LeftProp; DataItem='MainViewModel' (HashCode=38308053); target element is 'Gauge' (Name='gauge'); target property is 'Value' (type 'Double')

System.Windows.Data Error: 40 : BindingExpression path error: 'LeftProp' property not found on 'object' ''MainViewModel' (HashCode=38308053)'. BindingExpression:Path=LeftProp; DataItem='MainViewModel' (HashCode=38308053); target element is 'Gauge' (Name='scaledGauge'); target property is 'Value' (type 'Double')

 

Both of these errors point to the fact that the Binding is looking for the LeftProp in the MainViewModel.  The issue is clearly that the LeftProp does not exist on the MainViewModel, it exists on the LeftViewModel.

Thanks,

Terry

Dec 6, 2010 at 2:44 PM

I wasn't talking about that one... (that is another bug...this solution is a sample for 2 bugs)

When you run the above sample the first time (without clicking the button), you should see 2 errors in the output window

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='WpfGauge.Gauge', AncestorLevel='1''. BindingExpression:Path=NeedleTooltip; DataItem=null; target element is 'ContentControl' (Name=''); target property is 'Content' (type 'Object')