1

I have this Circle Slider:

enter image description here

And this is my TextBlock inside:

 <TextBlock Text="{Binding Path=Value, ElementName=knobSlider}" Foreground="White" FontFamily="Trebuchet MS" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.7,2.478" Margin="59,100,44,26" Width="47" /> 

How can i convert the Slider value from double to only one decimal place and put this text in the middle of the circle ?

4

1 Answer 1

2

Simply use the string format <TextBox Text="{Binding Value, StringFormat={}{0:#,#.0}}" />.

So in your case it would look like:

<TextBlock Text="{Binding Path=Value, ElementName=knobSlider, StringFormat={}{0:#,#.0}}" Foreground="White" FontFamily="Trebuchet MS" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.7,2.478" Margin="59,100,44,26" Width="47" /> 
Sign up to request clarification or add additional context in comments.

2 Comments

And how can i put my Text Block in the middle of the circle ? (both my slider and my text block are inside grid)
Well it's a different question and we'd need more details on how your grid is structured, but normally you play with the column/row sizes or padding/margin.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.