0
<TextBox x:Name="V2" Grid.Row="2" Grid.Column="8" Grid.ColumnSpan="3" Text="{Binding airPlane}".../>

In the above code, if I want to add more things in the "Text" property besides binding the airplane data, e.g. to add a unit called "Pounds", how to modify the code? Thanks!

6
  • 2
    In the above code There is no code ;) Commented Aug 23, 2017 at 7:29
  • Are you sure, it is supposed to be a TextBox? What is supposed to happen when someone enters Text into your Box, what should airplane and pounds be? But, since you are talking about Units, maybe this is enough for you: {Binding airplane, StringFormat={}{0}Pounds} Commented Aug 23, 2017 at 7:40
  • you should use textblock not the textbox in WPF. Commented Aug 23, 2017 at 7:41
  • Thank you very much, Rand and Rohit! {Binding airplane, StringFormat={}{0}Pounds} This is very helpful for me. I should use textblock instead. Can I bind 2 data using only 1 textblock split by a slash? Commented Aug 23, 2017 at 8:03
  • You can use MultiBinding <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} \ {1} "> <Binding Path="Value" /> <Binding Path="Value" /> </MultiBinding> </TextBlock.Text> </TextBlock> Commented Aug 23, 2017 at 8:18

1 Answer 1

1

You can use Converters for it. For more see WPF Converters

Sign up to request clarification or add additional context in comments.

2 Comments

I was about to say this.. Anyway, this is the best option I see fit.
@Ephraim Seems like OP went with StringFormat, wich in my opinion is the best option for his simple request. (see comments below question)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.