Posted 14 January 2019, 2:00 am EST - Updated 4 October 2022, 12:08 am EST
I try to render dynamically the current value within a TextBlock visually on top of the needle (pointer). See attached screenshot.
I used a FaceTemplate like this to render the value (currently centered within the LinearGauge (Orientation == Horizontal only):
<DataTemplate x:Key="ValueFaceTemplate">
<Border x:Name="displayValue">
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=gauge:C1LinearGauge}, Path=Value,Converter={StaticResource GvtConverter}}"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="26" FontWeight="Bold"
/>
</Border>
</DataTemplate>
I have access to the Border element named “displayValue” from the WPF logical tree and could apply some kind of transformation to correctly position the value at the X-Location of the pointer needle. I have tried various things, but could never get the transition of the text value to the correct location.
Is this even possible? If so, how to apply that? Can I inherit the C1LinearGauge and get access to some required methods to render this as required? Or can I use a modified face DataTemplate to get it work?