Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:16:47+00:00 2026-06-14T19:16:47+00:00

I want to setup a binding between a class instance and two WPF textboxes.

  • 0

I want to setup a binding between a class instance and two WPF textboxes. Still, the textboxes don’t change their status and I can’t figure out what I’m doing wrong.

XAML

<DockPanel>
   <TextBlock Style="{StaticResource caption}">Testing System</TextBlock>
   <TextBlock DockPanel.Dock="Left" x:Name="txt1" Text="DC"/>
   <TextBlock DockPanel.Dock="Right" x:Name="txt2"  Text="PD"/>
   <Button Height="20" Width="100" Click="clickBinding">Bind</Button>
   <Button Height="20" Width="100" Click="clickChangeBinding">Change Status</Button>
</DockPanel>

MainWindow.xaml.cs

private ADSbinding myADS = new ADSbinding();
private void clickBinding(object sender, RoutedEventArgs e)
{
   Binding b1, b2;

   b1 = new Binding();
   b2 = new Binding();
   b1.Source = myADS.DeviceConfigured;
   b2.Source = myADS.ProcessingData;


   b1.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
   b2.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;

   BindingOperations.SetBinding(txt1, TextBlock.TextProperty, b1);
   BindingOperations.SetBinding(txt2, TextBlock.TextProperty, b2); 
   }

   private void clickChangeBinding(object sender, RoutedEventArgs e)
   {
      myADS.changedata();
   }

Class:

public class ADSbinding : INotifyPropertyChanged
{
   public event PropertyChangedEventHandler PropertyChanged;

   private string deviceConfigured = "false";
   private string processingData = "false";

   public ADSbinding()
   {
      ProcessingData = "true";
   }

   // Get-Set methods
   public string DeviceConfigured
   {
      get { return deviceConfigured; }
      set 
      { 
         deviceConfigured = value;
         Changed("DeviceConfigured");
      }
   }
   public string ProcessingData
   {
      get { return processingData; }
      set
      {
         processingData = value;
         Changed("ProcessingData");
      }
   }

   private void Changed(string propertyName)
   {
      if (PropertyChanged != null)
         PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
   }

   public void changedata()
   {
      DeviceConfigured = "change";
      ProcessingData = "change";
    }
}

When pressing “clickBinding” the status changes, when “clickChangeBinding” it remains, by clicking “clickBinding” again it changes. Its a very straight forward attempt and I can’t figure out where the problem is. Anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:16:48+00:00Added an answer on June 14, 2026 at 7:16 pm

    When you create the bindings, you are setting Source to the properties of your object, not the object itself. You should specify the property name in the Binding constructor, and then set the source to your object:

        b1 = new Binding("DeviceConfigured");
        b2 = new Binding("ProcessingData");
        b1.Source = myADS;
        b2.Source = myADS;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to setup a simple site and I don't have any web development
I have some bindings that are setup as singletons. I want them to always
I want to setup a video on demand server which support Http protocol. It
I want to setup the TFS to build both Debug and Release versions of
I want to setup my test/dev environment for Alfresco on Rackspace cloud, since I'm
I want a setup like this: +- /ApplicationFolder -- App.exe -- Core.dll -- AnotherShared.dll
I want to setup a Method dispatch table and I am wondering if it
I want to setup a serialized task queue using NSOperationQueue but I'm a little
I want my setup.py to do some custom actions besides just installing the Python
I want to setup local domains like sub1.mydomain.dev and www.mydomain.dev on my local IIS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.