WPF TextBox Text multiple triggers -


I am doing a list of someone's contacts.

I have a ItemsControl which uses DataTemplates for different types of contact information such as phone number, email ... etc

In the case of phone numbers, I want the user to find the 4 text boxes, where they can edit . 4 due to the format (it can only edit numbers, the format is automatically generated):

+43 (2) 112233 - 2

as a text box Each part and I want to be a main text box with the full number written in that format . This means that when a user edits one of those 4 text boxes, the main text box is in a real time, which is filled with the formatted number.

I was working behind this code, but as I am now using the data template I want to reach this functionality in XAML in any of those ideas How to add triggers to 4 textboxes, the main text box is rebuilt with the correct format?

"post-text" itemprop = "text">

If I have found this correctly and you do not need to edit the phone number in the main textbox, You can use Multiband. Here's an example:

  & lt; Datatamplate x: key = "phone number number" & gt; & Lt; StackPanel Orientation = "Horizontal" & gt; & Lt; Text box name = "TBPN1" /> & lt; Text box name = "TBPN2" /> & lt; Text box name = "TBPN3" /> & Lt; Text box name = "TBPN4" /> & Lt; The text box isReadOnly = "True" & gt; & Lt; TextBox.Text & gt; & Lt; MultiBinding StringFormat = "{} + {0} ({1}) {2} - {3}" & gt; & Lt; Binding Path = "Text" ElementName = "TBPN1" UpdatesSource Trigger = "Property Change" / & gt; & Lt; Binding Path = "Text" ElementName = "TBPN2" UpdatesSource Trigger = "Property Change" / & gt; & Lt; Binding path = "text" elementName = "TBPN3" updatesSourceRetiger = "Property Change" / & gt; & Lt; Binding Path = "Text" ElementName = "TBPN4" Update Sorcerer = "Property Change" / & gt; & Lt; / MultiBinding & gt; & Lt; /TextBox.Text> & Lt; / Text box & gt; & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt;  

This main textbox will be pressed once in a corner of one of the other 4 text boxes

Update : the data source To 'update', I will do the following:

The implementation of the Ennotifypronet to Phononumber class varies according to:

  Public category phone number: INotifyPropertyChanged {public Event Property PreviewAventHandler PropertyChanged; Private Zero OnPropertyChanged (string propertyName) {var handler = property changed; If (handler! = Null) {property changed (this, new property change event event (property name)); }} Private string m_CountryCode; Public string countrycode {get {return m_CountryCode; } Set {m_CountryCode = value; ComputeFullNumber (); OnPropertyChanged ("Country Code"); }} Private string m_AreaCode; Public string fieldcode {get {return m_AreaCode; } Set {m_AreaCode = value; ComputeFullNumber (); OnPropertyChanged ("Areacode"); }} Private string m_Number; Public string number {receive {return m_Number; } Set {m_Number = value; ComputeFullNumber (); OnPropertyChanged ("number"); }} Private string m_Suffix; Public string suffix {get {return m_Suffix; } Set {m_Suffix = value; ComputeFullNumber (); OnPropertyChanged ("suffix"); }} Public string integer {get; Private set; } Private Zero computeFullNumber () {FullNumber = string.Format ("+ {0} ({1}) {2} - {3}", m_CountryCode, m_AreaCode, m_Number, m_Suffix); OnPropertyChanged ("FullNumber"); }}  

Then your datatymelet becomes:

  & gt; Datamapplet x: Key = "Phone Number Template" & gt; & Lt; StackPanel Orientation = "Horizontal" & gt; & Lt; Text box text = "{binding path = countrycode, update resource trigger = asset changed}" /> & Lt; Text box text = "{binding path = regioncode, update resource reset = property changed}" /> & Lt; Text box text = "{binding path = number, updated source = catalyzed = changed}" /> & Lt; Text box text = "{binding path = suffix, update authoritrgr = property changed}" /> & Lt; Text box text = "{binding path = absolute number, mode = wrench}" IsReadOnly = "true" /> & Lt; / StackPanel & gt; & Lt; / DataTemplate & gt;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -