Data bind to a Shared Property WPF

I have a Class with Shared Properties
This Class holds the Name and ID of the Current User.
It all works fine until I try to databind to the Shared Values.

When I update the Shared Values in Code the Displayed Values stay the same.
But if I update the Displayed Values (In the Text box) the Bound Shared Properties DO update.

Class
Public Class CurrentUser
    Inherits CommonViewModelBase

    Private Shared _name As String = "No Name"
    Private Shared _ID As Integer
    Private Shared _thisInstance As CurrentUser


    Public Shared Property name As String
        Get
            Return _name
        End Get
        Set(value As String)
            _name = value
            _thisInstance.OnPropertyChanged(NameOf(name))
        End Set
    End Property

    Public Shared Property ID As Integer
        Get
            Return _ID
        End Get
        Set(value As Integer)
            _ID = value
            _thisInstance.OnPropertyChanged(NameOf(ID))
        End Set
    End Property

    Protected Sub New()
        'initialization code goes here

    End Sub

    Public Shared Function GetCurrentUser() As CurrentUser
        '
        ' initialize object if it hasn't already been done
        '
        If _thisInstance Is Nothing Then
            _thisInstance = New CurrentUser
        End If
        '
        ' return the initialized instance
        '
        Return _thisInstance
    End Function

End Class

Open in new window


This Property is in the View Model of the Main Window
Public Property localCurrentUser As CurrentUser = CurrentUser.GetCurrentUser

Open in new window


xaml
<StackPanel Orientation="Horizontal" Grid.Row="4" HorizontalAlignment="Right" DataContext="{Binding localCurrentUser}">
            <TextBlock Name="StaffNameTextBlock1" Text="Staff Name (Click to Change) "/>
            <TextBlock x:Name="StaffNameTextBlock" Text="{Binding name, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
        </StackPanel>

Open in new window



What am I doing Wrong?
p-platerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
>>When I update the Shared Values in Code the Displayed Values stay the same.

Typically the interface will only update when it is changed or instructed to do so from code.  So your behavior is what I would expect.  When you want to modify the values from code you need to force the UI to update or you modify the values in the UI directly.
p-platerAuthor Commented:
So how do I tell the UI to update?

Isn't that what the INotifyPropertyChanged is supposed to do?
(I am implementing the INotifyPropertyChanged in the Base class)
p-platerAuthor Commented:
It Appears I need to raise a StaticPropertyChanged event.
I can only find C# examples - can you help me convert it to VB?

public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static void RaiseStaticPropertyChanged(string propName)
{
    EventHandler<PropertyChangedEventArgs> handler = StaticPropertyChanged;
    if (handler != null)
        handler(null, new PropertyChangedEventArgs(propName));
}

Open in new window

Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

AndyAinscowFreelance programmer / ConsultantCommented:
https://msdn.microsoft.com/library/ms743695%28v=vs.100%29.aspx
The above microsoft site gives both a C# and the equivalent VB code.  It looks to be pretty much what you have the C# code in your example.
p-platerAuthor Commented:
I sorted it out Finally.
I simply put a Non-Shared Property in the Shared Class and whenever the Shared Property is Updated I update the Non-Shared Property and raise the Standard PropertyChanged event.

Seems to work fine

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
p-platerAuthor Commented:
Other Comments didn't solve the Question.
I Experimented until I managed to get it to work
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.