Reputation: 456
I have a textbox
whose text value I want to bind based on the values selected in two other controls.
For example, I have a ListBox
and I choose a value say "Blue" and one other TextBox
whose text value is say a Name - "Sam".
So I want my TextBox.Text
value to be like "Blue_Sam".
Is this possible?
Upvotes: 2
Views: 1227
Reputation: 3966
well, if u dont want a complicated solution then u should try this--->
private void listPicker1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListPickerItem lpi = (sender as ListPicker).SelectedItem as ListPickerItem;
var text = urTextBox.Text;
urTextBox.Text = lpi.Content + "_" + text;
}
private void OtherTextBoxChanged(object sender, TextChangedEventArgs e)
{
var Othertext = (sender as TextBox).Text
var text = urTextBox.Text;
urTextBox.Text = text + "_" + Othertext;
}
Upvotes: 1
Reputation: 32449
You can use MultiBinding
:
<TextBox>
<TextBox.Text>
<MultiBinding StringFormat="{}{0} + {1}">
<Binding ElementName="yourComboBox" Path="SelectedText" />
<Binding ElementName="yourTextBox" Path="Text" />
</MultiBinding>
</TextBox.Text>
</TextBox>
Upvotes: 2