I have a description´s textbox that I want to add to some constant text in the window title. Like "Description: " + Description. Can I easily do this in the xaml?
My first approach was to create a new property that returns the Description´s value with the constant string. The problem is that I don´t get PropertyChanged event so the window´s title doesnt refresh. I was thinking of creating an event on the Description´s seter but I think its too ugly.
Can you help my out?
Checkout StringFormat when using Binding.
Title="{Binding Path=Description, StringFormat=Description: {0}}"
If you have the textbox and you want to use its text, it works the same way. Give the Textbox a name and use ElementName
Title="{Binding ElementName=myText, Path=Text, StringFormat=Description: {0}}"
You can achieve this very easily using DataBinding
Create a field Description in ViewModel/DataContext, and use StringFormat
Title = "{Binding Path=Description,Mode=OneWay, StringFormat = Description: {0}}"
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