You are here: Home Support Blog Tag: Auto Resizing

Tag: Auto Resizing

2008.06.26 06:21:48
admin

Lately there are numbers of sending email asking how to auto resizing the gauge , So i have decided to post a solution here .

There are couple of way how this can be done , but i will post a solution which i have posted in the forum .

and i will described how it works here :

1. We create a user control call MyGauge , in the MyGauge override the OnMeasure method .

private Size _oriSize;
public MyGauge()
{
InitializeComponent();
_oriSize = new Size(this.Width, this.Height);
}

protected override Size MeasureOverride(Size constraint)
{
this.circularGauge1.LayoutTransform = new ScaleTransform(constraint.Width / _oriSize.Width, constraint.Height / _oriSize.Height);
return base.MeasureOverride(constraint);
}

 

What we are doing here first we save the original size , whenever the user control get resize , user control will re measure with the new size . We calculate the ratio by doing a new size / old size , then appy a scale transformation to it .

 

Once it is done . You have a usercontrol that will resize the gauge .

Now , we need to use this gauge in a window .

We create a new project , then embed the newly created UserControl in the XAML


<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:lala="clr-namespace:Demo;assembly=Demo"
    Title="Window1" Height="200" Width="200">
    <Grid>
        <l:MyGauge></:MyGauge>
    </Grid>
</Window>



But when you run the project , as you resize the window , the control does not resize !!

The solution to this problemi is in XAML

change

 <l:MyGauge Width="Auto" Height="Auto"></l:MyGauge>
 

Now the window will resize the user control automatically .

 download the application from here 

 http://nextwavesoft.com/images/fbfiles/files/Demo-ae3449dbe05da0c8a1ca07654d969596.zip

 

 

 

 

 

 


  Auto Resizing | Gauge | XAML | Control | WPF
Comments 0Hits: 1578  


ieee.logo.jpg  K. Y. Sim, C. S. Low, F.-C. Kuo, "Automatic Testing of Financial Charting Software Component: A Case Study on Point and Figure Chart", Proceedings of 2009 International Conference on Computer Science and its Applications, IEEE Press, to appear.

Nextwave Suite for WPF, with Chart and Gauge, is compatible with:

Download Microsoft .net Framework 4.0

Microsoft Visual Studio 2010

Download Microsoft .net Framework 3.5

About Windows Presentation Foundation

 Visual Studio 2008

Expression Blend

About XAML

Calendar

< July 2010 >
Mo Tu We Th Fr Sa Su
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Latest Comments

Online Support

online support

Login

Polls

In future, what kind of release you are looking forward?