Note that there are some explanatory texts on larger screens.

plurals
  1. POwpf c# databinding on object
    primarykey
    data
    text
    <p>say I have this control:</p> <pre><code>public partial class bloc999 : UserControl { bloc999Data mainBlock = new bloc999Data(); public bloc999() { InitializeComponent(); mainBlock.txtContents = "100"; base.DataContext = mainBlock; } } </code></pre> <p>in the xaml:</p> <pre><code> &lt;TextBox Margin="74,116,106,0" Name="txtContents" Text="{Binding Path=txtContents, UpdateSourceTrigger=PropertyChanged,Mode = TwoWay}" /&gt; &lt;TextBox Margin="74,145,106,132" Name="txtContents2" Text="{Binding Path=txtContents2, UpdateSourceTrigger=PropertyChanged,Mode = TwoWay}" /&gt; </code></pre> <p>Then I have this class:</p> <pre><code>public class bloc999Data : INotifyPropertyChanged { string _txtContents; string _txtContents2; public event PropertyChangedEventHandler PropertyChanged; void NotifyPropertyChanged(string propName) { if (this.PropertyChanged != null) this.PropertyChanged( this, new PropertyChangedEventArgs(propName)); } public string txtContents2 { get { return this._txtContents2; } set { if (int.Parse(value) &gt; int.Parse(this._txtContents)) { this._txtContents2 = "000"; } else this._txtContents2 = value; NotifyPropertyChanged("txtContents2"); } } public string txtContents { get { return this._txtContents; } set { this._txtContents = value; NotifyPropertyChanged("txtContents"); } } } </code></pre> <p>Ok now say I have A button on the form and I do this in the code:</p> <pre><code>mainBlock.txtContents2 = "7777777"; </code></pre> <p>It puts 000 in the textbox, but If i just type in manually, in the textbox (txtContents2), the setter code is called but for some reason the textboxes value does not change, the instance value does change. help?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload