I was wondering something, and couldn't find any relevant topics. I have following binding :
Content="{x:Static resx:Resource.Form_OtherOption_Description}"
This will place a string in a label. What i was asking myself is if i can add a ":" after that binding, not in code, just in xaml. The label represent something like "Name :". But adding the ":" as part of the binding is not an option.
Edit
I'm working in 3.5 version
Any suggestions.
Thanks in advance.
Data binding is a mechanism in XAML applications that provides a simple and easy way for Windows Runtime Apps using partial classes to display and interact with data. The management of data is entirely separated from the way the data is displayed in this mechanism.
Data binding is a mechanism in WPF applications that provides a simple and easy way for Windows Runtime apps to display and interact with data. In this mechanism, the management of data is entirely separated from the way data. Data binding allows the flow of data between UI elements and data object on user interface.
WPF binding offers four types of Binding. Remember, Binding runs on UI thread unless otherwise you specify it to run otherwise. OneWay: The target property will listen to the source property being changed and will update itself.
Two way binding is used when we want to update some controls property when some other related controls property change and when source property change the actual control also updates its property.
You could accomplish this with something like:
<TextBlock Text="{Binding Source={x:Static resx:Resource.Form_OtherOption_Description}, StringFormat={}{0}:}" />
Edit: <Label>
s Content
property does not respect the StringFormat
property of a binding apparently. Which I've found has been moved to the ContentStringFormat
property on the <Label>
.
<Label Content="{x:Static resx:Resource.Form_OtherOption_Description}" ContentStringFormat="{}{0}:" />
If you're using WPF 4.0, you could also do this:
<TextBlock> <Run Text="{Binding SomeLabel}"/> <Run Text=":"/> </TextBlock>
This actually concatenates the two strings coming from two Run
tag and copied into TextBlock.Text
property!.
Using this approach you can even bind to different properties in presenter, and display it in a single TexBlock
. See this excellent example:
Can we concat two properties in data binding?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With