Click here to Skip to main content
15,348,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,

I've a property in a separate file class with interface Inotifypropertychanged
When I modify the source property the target not change.

I've tried set Mode="ToWay" but not working

What can I do to find out what's wrong? how can i solve?

What I have tried:

I tried to bidding this property to a TextBox target property Text.
<pre>  public class Intestazione : INotifyPropertyChanged
        #region Propery Changed
        public event PropertyChangedEventHandler PropertyChanged;

        private void RaiseProperChanged([CallerMemberName] string caller = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(caller));


        private string _intestazione;

        public  string Denominazione
            get => _intestazione;
                _intestazione = value;

    d:DataContext="{d:DesignInstance Type=local1:Intestazione}"

<stackpanel orientation="Vertical">

                <textblock x:name="txtBlock_intestazione" style="{StaticResource 
                           TbIntestazione}" text="{Binding Denominazione}">

When I modify the source property the target not change.
Updated 23-Mar-21 8:59am
Richard Deeming 19-Mar-21 13:10pm
You're using the [CallerMemberName] attribute, so your property changed call should simply be RaisePropertyChanged(); - ie:
public string Denominazione
    get { return _intestazione; }
        _intestazione = value;

The compiler will automatically insert the name of the current property into the parameter for you.

Beyond that, you need to show the code you're using to set the "source property". If you're changing the property on the TextBlock, that's simply going to break the binding; it won't update the property on the Intestazione instance.
ZMirkone 19-Mar-21 15:23pm
thanks you, I tried but not working yet
Gerry Schmitz 19-Mar-21 13:48pm
XAML is case-sensitive; I don't know what you think you're showing.
ZMirkone 19-Mar-21 16:30pm
I've controlled the name more times, it's correct.
George Swan 20-Mar-21 20:12pm
Try this:
                <TextBlock x:name="txtBlock_intestazione" Style="{StaticResource 
                 TbIntestazione}" Text="{Binding Path=Denominazione, UpdateSourceTrigger=PropertyChanged}"/>
Kenneth Haugland 21-Mar-21 17:07pm
Where did you actually set the instance to the DataContext. It's not entirely clear to me. Normally I would set:
ZMirkone 23-Mar-21 14:56pm
Yes, I've dichiarate the datacontex

1 solution

I rewrote all the ViewModels and now it works correctly. Thanks everyone for the answers

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900