Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

WPF Tank Fill Effect

Two issues.

 

1. I have to use the "Fill" property to set the color of the TankDouble bar.  Where are the properties defined in the NI user documentation for the WPF Tank or TankDouble?  I do not see Fill in the list, but it obviously is the property that controls the fill color.

http://zone.ni.com/reference/en-XX/help/375857A-01/html/allmembers_t_nationalinstruments_controls_ta...

 

 

2. I use the following styling on a TankDouble.  I want to remove the shading effect on the tank fill.  How can I do that, i.e., what Property controls the shading?

 

 

<Style x:Key="TankStyle" TargetType="{x:Type ni:TankDouble}">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="Height" Value="Auto" />
<Setter Property="Width" Value="Auto" />
<Setter Property="Margin" Value="1,1,1,1" />
<Setter Property="Range" Value="{Binding Range, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />

<Style.Triggers>
<DataTrigger Binding="{Binding InRange, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Fill" Value="#FF32CD32"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding InRange, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="False">
<Setter Property="Fill" Value="#FF49A4FF"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>

 

Thanks!!!

 

 

0 Kudos
Message 1 of 3
(2,403 Views)

Sorry about the trouble with the documentation: it appears the base class properties are not being pulled in. I have created a task to correct this.

 

The Fill property is defined on the LinearNumericPointer<TValue,TOffset> generic base class.

 

Unfortunately, the shading effect is built into the skin of the tank, and there is no configuration property available to change its visibility. Instead of creating a custom control skin, you could use a derived type to remove the element from the default template:

 

public class EffectFreeTankDouble : TankDouble {

    public override void OnApplyTemplate( ) {
        base.OnApplyTemplate( );

        var track = (Panel)Track;
        var effect =
            track.Children
                 .OfType<Rectangle>( )
                 .First( HasHighlightEffect );
        track.Children.Remove( effect );
    }

    private static bool HasHighlightEffect( Rectangle rectangle ) {
        var fill = rectangle.Fill as SolidColorBrush ?? Brushes.Black;
        return fill.Color == Colors.White
            && rectangle.OpacityMask != null;
    }

}
~ Paul H
0 Kudos
Message 2 of 3
(2,390 Views)

Just wanted to let you know that Measurement Studio 2019 added additional resource keys to control the appearance and visibility of numeric visuals:

<ni:TankDouble>
    <ni:TankDouble.Resources>
        <Visibility x:Key="{x:Static niPrimitives:ControlConfiguration.HighlightPartVisibilityKey}">Collapsed</Visibility>
    </ni:TankDouble.Resources>
</ni:TankDouble>
~ Paul H
0 Kudos
Message 3 of 3
(1,833 Views)