Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
Really trivial WPF Binding refuses to work

Data Binding is supposed to be the CENTRE OF FOCUS and even the "Raison d'etre" of apps written using WPF, but sadly the Binding in my really simple test of it as shown below simply DOES NOT WORK.... and so far, nobody can seem to tell me why it does not work. It started in my main code base, so in trying to debug the problem, I have created this trivial window (named "bindingtest") that has a similar Customers DataGrid that is populated from an Sql Db. The ItemsSource Binding for that works just fine.

Above the Grid I have a Status line showing Db Name, Total records, and (if it worked) the currently selected record in the datagrid. Pretty simple stuff eh ?

Basically the Currently selected item is a simple TextBlock with its .Text bound to a FULL property in the codebehind file, which of course fully supports PropertyChanged(). (Shown in image below).

    private int customersTotal;
    public int CustomersTotal
    {
        {return customersTotal; }
        set {customersTotal = value;
            OnPropertyChanged ( nameof ( CustomersTotal ) );}
    }

The Window and XAML root file names are "bindingtest" The binding specified below of "BindTest" is declared in of the XAML and shows no errors (like the '...' under BindTest) so clearly recognises the source of "bindingtest ? as being a valid DataContext.

<local:bindingtest x:Key="BindTest"/>

Here is the pretty trivial TextBlock that is a part of the Status line but which refuses to call the Getter for the Property "CustomerCurrent" in XAML Note the hover information !! CustomerCurrent is in this files code behind file...

enter image description here

Also, I have tried using the SAME Datacontext=this; in codebehind - same NON Result. Property Getter is still never called. The Property is set via the line below in the Grid.SelectionChanged event handler for the Datagrid in codebehind by :

int newsel = CustomersGrid. SelectedIndex;
// Update the problem property !!
CustomerCurrent = newsel;

This works correctly, and the Getter for CurrentCustomer is called as expected, and the value is changed as relevant.

I have tried every possible option foud onthe internet forums etc, but NOTHING works, it stubbornly refuses to call the "CustomerCurrent" Property Getter and update the Text of the TexBlock on the screen.

For background, I have used Value Converters in this window on a more complex example of this testing window, and they work just fine, so some binding does work, just not this most tirvial of examples.

CAN AYONE PLEASE TELL ME WHY THIS DOES NOT WORK ?? I am going totally mad.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!