Home Forums WPF controls Xceed Toolkit Plus for WPF problem with gauge needle on resize

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • sonja
    Participant
    Post count: 7
    #44657 |

    hi,
    When i try to resize gauge control the gauge needle doesn’t resize proportionally. So if I resize it to small gauge the needle is bigger than the circle. How can I make the gauge needle to resize proportionally with the gauge?
    Thanks

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    Currently, the needle is set based on the property RadialGauge.PointerTemplate. So a template, with a fixed size is defined and used. The default pointerTemplate is the “DefaultPointerTemplate” in file :
    -Xceed.Wpf.Toolkit/Gauge/Themes/Aero2.NormalColor.xaml (for Windows8 and up)
    -Xceed.Wpf.Toolkit/Gauge/Themes/Generic.xaml (for other Windows)

    It consist of an orange arrow of 100 pixels in height. So whatever size is your RadialGauge, the needle will have 100 pixels of height.

    You can always define your own needle by setting a new RadialGauge.PointerTemplate and setting your wanted height. You could use a small or big needle, depending on your needs.

    Bu if you really want a dynamic needle that resizes as you resize your RadialGauge, you could try modifying the RadialGauge template. Go in the file mentioned previously and look for the style of “RadialGauge”. In its ControlTemplate, look for its “Pointer”. Try wrapping it in a Viewbox where you can adapts the needle multiplier :

    <Viewbox Width=”{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.5}”
    Height=”{Binding ActualHeight, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=0.5}”
    StretchDirection=”UpOnly”
    Stretch=”Uniform”>
    <local:Pointer x:Name=”PART_Pointer”
    ….
    </local:Pointer>
    </Viewbox>

    public class MultiplyConverter : IValueConverter
    {
    public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
    {
    double size = ( double )value;
    double multiplier = Double.Parse( ( string )parameter, CultureInfo.InvariantCulture );
    return size * multiplier;
    }

    public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
    {
    throw new NotImplementedException();
    }
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.