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

  • SEARCH
  • Home
  • 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 6893407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:39:17+00:00 2026-05-27T06:39:17+00:00

In WPF, I have a static Customer object in the definition for MainWindow.xaml.cs. This

  • 0

In WPF, I have a static “Customer” object in the definition for MainWindow.xaml.cs. This customer has a publicly accessible string Name property. In expression blend 4, I click on the “Advanced Options” box beside the “Text” property for the TextBox that I would like to bind to the customer name. I then click “Data Binding…” -> “Element Property” -> “window” under “scene elements” -> click the expander arrow beside “ActiveCustomer” -> then click “Name” -> “OK”. The binding is to a readonly TextBox, so One Way binding is acceptable as the default. But when I run my app, it doesn’t display the customer’s name. Any Suggestions?

<TextBox x:Name="AIAHNameTextBox" Height="26" Canvas.Left="90" TextWrapping="Wrap" Canvas.Top="8" Width="100" IsReadOnly="True" VerticalContentAlignment="Center" Text="{Binding ActiveCustomer.Name, ElementName=window, Mode=OneWay}" />

ActiveCustomer is an instance of my Customer class:

namespace WPFBankingSystem
{
    public enum CustomerStatus
    { Open, Closed }
    public enum TransferType
    { CheckingToSaving, SavingToChecking }

    [Serializable]
    public class Customer
    {
        private string address;
        private Checking chkAcc;
        private string name;
        private int pin;
        private Saving savAcc;
        private string ssn;
        private AccountStatus status;
        private string tel;

        public string Address
        {
            get { return address; }
            set { address = value; }
        }
        public Checking ChkAcc
        {
            get { return chkAcc; }
            set { chkAcc = value; }
        }
        public string Name
        { get { return name; } }
        public int Pin
        {
            get { return pin; }
            set { pin = value; }
        }
        public Saving SavAcc
        {
            get { return savAcc; }
            set { savAcc = value; }
        }
        public string Ssn
        { get { return ssn; } }
        public AccountStatus Status
        {
            get { return status; }
            set { status = value; }
        }
        public string Tel
        {
            get { return tel; }
            set { tel = value; }
        }

        public void create(string Name, string Address, string TelephoneNumber, string SSN, int PIN)
        {
            this.address = Address;
            this.name = Name;
            this.pin = PIN;
            this.ssn = SSN;
            this.status = AccountStatus.Open;
            this.tel = TelephoneNumber;
        }
        public void delete()
        {
            if (this.chkAcc != null)
            { chkAcc.close(); }
            if (this.savAcc != null)
            { savAcc.close(); }
        }
        public bool hasChkAcc()
        { return (this.chkAcc != null) ? true : false; }
        public bool hasSavAcc()
        { return (this.savAcc != null) ? true : false; }
        public void show()
        { }
        public void transfer(double Amount, TransferType Type)
        {
            if(this.hasChkAcc() && this.hasSavAcc())
            {
                switch(Type)
                {
                    case TransferType.CheckingToSaving:
                        this.chkAcc.Balance -= Amount;
                        this.savAcc.Balance += Amount;
                        break;
                    case TransferType.SavingToChecking:
                        this.savAcc.Balance -= Amount;
                        this.chkAcc.Balance += Amount;
                        break;
                }
            }
            else
            { throw new Exception("You do not have both a checking account and a saving account."); }
        }

        public Customer()
        { }
        ~Customer()
        { this.delete(); }
    }
}

Inside MainWindow.xaml.cs, the customer is defined just as a public Customer object:

public Customer ActiveCustomer
{ get; set; }
  • 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-05-27T06:39:17+00:00Added an answer on May 27, 2026 at 6:39 am

    You cannot bind to static properties like you can to instance properties. The property ActiveCustomer then does not exist on the element named window it exists in the class MainWindow. You should be able to fix the binding by using a Source in conjunction with x:Static:

    {Binding Name, Source={x:Static local:MainWindow.ActiveCustomer}}
    

    Note that x:Static has a very specific syntax, it does not allow an arbitrary path or the like.

    Even if the binding works this is problematic though as you cannot implement INPC for static properties, so if you assign a new object to ActiveCustomer there will be no update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a wpf project I have this XAML code <Window xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
I have following wpf: <Style x:Key=HyperlinkStyle TargetType=Hyperlink> <Setter Property=Foreground Value={StaticResource {x:Static SystemColors.ControlTextBrushKey}}/> <Setter Property=TextDecorations
I have WPF Form which has many buttons with the same code. Appearance of
The CollectionViewSource.GetDefaultView() method is not in Silverlight 3. In WPF I have this extension
I have a WPF form with ListView (resultsList) and I have a static method
I have a wpf datagrid that has it's columns generated dynamically in code and
Everyone, I have a WPF app that has a canvas that I have wrapped
I have been experimenting with WPF and rendering strict XAML markup in a web
I have a WPF application with the main Window class called MainWindow. Since I
I have a WPF-application with a mainwindow and different pages. On one of the

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.