3

Is there a way have a single textbox bind to two things. I want to have one binding set to "OneWay" and the Other set to "OneWayToSource". Basically I want to combine these two textboxes into one (and preferably with little to no code behind).

<TextBox Text="{Binding Path=ActionParameter.Value, Mode=OneWayToSource}" /> <TextBox Text="{Binding Path=StatusSignal.Value, Mode=OneWay}" /> 

1 Answer 1

4

You can use MultiBinding to set 2 or more bindings to your TextBox

Example:

<TextBox> <TextBox.Text> <MultiBinding StringFormat="{}{0}{1}"> <Binding Path="ActionParameter.Value" Mode="OneWayToSource" /> <Binding Path="StatusSignal.Value" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> 

But depending on what you need to do with the 2 properties you may need to use a IMultiValueConverter to process the properties.

Example:

<TextBox> <TextBox.Resources> <local:TextConverter x:Key="MyConverter"/> </TextBox.Resources> <TextBox.Text> <MultiBinding Converter="{StaticResource MyConverter}"> <Binding Path="ActionParameter.Value" Mode="OneWayToSource" /> <Binding Path="StatusSignal.Value" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.