Search code examples
c#uwpuwp-xamlupdatesourcetrigger

update source trigger of one control should effect the other control


I am using a third party control for datagrid. I have implemented property changed event in model class and it is working when i use

 Text="{Binding itemQty, UpdateSourceTrigger=propertychanged}"

it is even updating in my data source, but i have another textbox here data is not retrieving from the item source though item source is updated with new values. I want to display the data with property changed event of first textbox and the rows are dynamic, so i can't directly call them. If i refresh the data source it is displaying but i can't use that process as it is time taking process when items are many.


Solution

  • I want to display the data with property changed event of first textbox and the rows are dynamic

    The problem is you have not set Mode=TwoWay for your Text property. And UpdateSourceTrigger defines constants that indicate when a binding source is updated by its binding target in two-way binding.

    <TextBox Text="{Binding Info,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
    <TextBox Text="{Binding Info}"/>
    

    Code behind

    private string info { get; set; }
    public string Info
    {
        get { return info; }
        set
        {
            info = value;
            OnPropertyChanged();
        }
    }
    
    public event PropertyChangedEventHandler PropertyChanged;
    
    private void OnPropertyChanged([CallerMemberName] string properName = null)
    {
        if(PropertyChanged != null)
        this.PropertyChanged(this,new PropertyChangedEventArgs(properName));
    }