Click here to Skip to main content
15,888,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Boyz and Girlz,

I am calling a routine to update the DB from inside OnPropertyChanged(propertyname) like so...

protected void OnPropertyChanged(string name)
        {
            // Some TEMP employee property changed
            const string PROCNAME = "OnPropertyChanged";

            try
            {
                PropertyChangedEventHandler handler = PropertyChanged;
                if (handler != null)
                {
                    handler(this, new PropertyChangedEventArgs(name));

                    // Call routine to perist changes to DB
                    tempMethods.UpdateTempFromCollection(this, name);
                }
            }
            catch (Exception ex)
            {
                ProgLog.Log(ex.Message, PROCNAME, MODNAME);
            }
        }


Now I need to get the disposition back to the WPF window but since the DB update is begin called via INotifyPropertyChanged on a property INSIDE of a collection it is not clear how to trap the disposition of the DB update and return user feedback to the window.

How have some of you handled this?

What I have tried:

I tried creating a feedback class that implements INotifyPropertyChanged and allowing my DB update routine to change a property inside this class. This approach results in the PropertyChangedEventHanlder begin NULL all the time - even if the triggering property is successfully modified.

My intention was to bind a label inside my WPF window to the DBFeedback property of my feedback class. No worky. :(

<Label x:Name="lblFeedback" Width="235" Height="30" Content="{Binding Path=UserFeedback.DBUpdate}" Grid.Column="1"  HorizontalAlignment="Left" Margin="170,346,0,0" Grid.Row="1" VerticalAlignment="Top" Background="#FFEED8D8"/>
Posted
Updated 25-Sep-18 6:50am
v3
Comments
Graeme_Grant 25-Sep-18 20:22pm    
do you see any binding errors in the debug output?
Member 13944054 26-Sep-18 16:57pm    
Hey, Grant.

Hope. No binding errors. At least not that I see. There's a bunch of stuff in the output window, though.
Graeme_Grant 27-Sep-18 18:35pm    
Sounds like you have not set the DataContext.
Member 13944054 27-Sep-18 18:41pm    
I set the datacontext in the code behind for my xaml window but the class that my feedback label is bound to gets "newed up" inside the class that the datacontext points to. I'm not sure that's kosher. Would that be nested binding and is that allowed?
Graeme_Grant 27-Sep-18 20:58pm    
You can break data binding if you "renew" an object rather than/clear/reset properties. I can't see from the code that you have posted. So be careful.

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