Trying to set the text inside progressBar and i am getting properly with Setters. but i have to concat this value with:
{TemplateBinding Value}+"% Completed
How do i concat with some other Text.
Code where text printed inside progressbar:
<Border x:Name="whiteBorder" >
<ContentPresenter x:Name="perHolder" Content="{TemplateBinding Value}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
</Border>
Silverlight version 3.0
To augment values, use a class that implements an
IValueConverter, which is described here:http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx
In essence, a class that implements
IValueConverterwill intercetpt thevaluein a method calledConvert. The value you return from this method is the value you really want to display. Consider:namespace Sharp {
}
Notice in the example above the value converter is in the namespace
Sharp. Now we add this to the XAML definition:The last line is the namespace where our value converter exists (that is,
lolwill now point to theSharpCLR-namespace.Next we add the class to our
Windowresources:this creates an instance of the class that you can use in the XAML. So, so far our XAML looks like this:
Now we simply add it to your content presenter like so:
This tells the
ContentPresenterthat when it goes to present the value, it should use theTheValueConverterinstance, which is an instance of ourValueConverter. Two things to be careful of: (1) Make sure that you use the name of the instance (TheValueConverter) and not the class definition (MyConverter). (2) Make sure to wrap the instance name in{StaticResource}.