Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF progress
Hi,
 
I need to bind a TextBlock to a progress bar. I.e., the TextBlock should show the value of the progress bar, which is the progressbar.value property. I tried binding, but I guess I am doing it the wrong way as it does not work. Can anyone help me??
 
Cheers,
Roshini
Posted 26-Jan-11 10:29am
Edited 26-Jan-11 12:18pm
v2
Comments
Christian Graus at 26-Jan-11 15:47pm
   
Perhaps if you posted code, we could see how you're doing it. The obvious way is to just handle the event and set the text, but I would agree you should be able to do what you want in WPF.
roshini.johri at 26-Jan-11 16:22pm
   
Actually what u said worked!! I was doing things in a more complicated manner! Sometimes the easiest methods are the most diff to find!! :D cheers
Christian Graus at 26-Jan-11 17:23pm
   
Yeah, that was always going to work, but it's worth learning how to make binding work.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It's fairly easy to bind a ProgressBar's Value property to a TextBox control's Text property.
 
Example Xaml:
---------------
 
<ProgressBar Value="{Binding X}"
     Height="28" HorizontalAlignment="Left"
     Margin="62,40,0,0" Name="progressBar"
     VerticalAlignment="Top" Width="332" />
 
<TextBox Text="{Binding ElementName=progressBar, Path=Value}"
     Height="23" HorizontalAlignment="Left" Margin="62,86,0,0"
     Name="textBox" VerticalAlignment="Top" Width="120" />
 
Note: TextBlock would work the same as TextBox (since you asked for TextBlock in your question).
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 CPallini 155
3 PIEBALDconsult 150
4 BillWoodruff 148
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 26 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100