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 8148441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:38:48+00:00 2026-06-06T14:38:48+00:00

I have created a wpf vb.net project and am trying to set a simple

  • 0

I have created a wpf vb.net project and am trying to set a simple databing. I’m not quiet sure how to set my DataContext = this; in the codebind. Currently when i run the program my Label never is updated. I have included my code below. What I’m i missing?

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Label Content="{Binding person.Name}"/>
    </Grid>
</Window>

Class MainWindow 
    Private Property person As New Person()

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        person.Name = "Poco"
    End Sub
End Class

System.ComponentModel

Public Class Person
    Implements INotifyPropertyChanged

    Private _name As String
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value

            OnPropertyChanged(New PropertyChangedEventArgs("Name"))
        End Set
    End Property

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
        If Not PropertyChangedEvent Is Nothing Then
            RaiseEvent PropertyChanged(Me, e)
        End If
    End Sub
End Class
  • 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-06T14:38:49+00:00Added an answer on June 6, 2026 at 2:38 pm

    This is close – you need to name your label in the XAML (so that you can reference it from the code behind) and then specify the path within the bound object to the data you would like to bind. In this case you will be binding an object with a Name property whose content you would like to assign to the label text:

    <Label Name="MyLabel" Content="{Binding Path = Name}"/>
    

    and then in your code you need to set the DataContext of the label to the object you would like to have it bound to, in this case a specific instance, somePerson of the class Person :

    Private somePerson As New Person
    
    Public Sub New()
        InitializeComponent()
        MyLabel.DataContext = somePerson
        somePerson.Name = "Poco"
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have created a beautifully designed .NET WPF desktop application. We are installing the
I have set up cruisecontrol.net cs for my project that has a number of
I have created a WPF UserControl called ChartPanel to my .NET 4.0. I am
I have created successfully a wpf user control inheritance like this: <base:BaseUserControl x:Class=wpfcontrolinheritance.InheritedUserControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
I'm relatively new to C# and .Net, and this is my first WPF project,
I am trying to create a WPF project with MVVM and ADO.Net Entity Framework.
I have created some tests in my WPF application. Right now I am working
I have created styled a ListBox in WPF so that it is rendered as
We have created a WCF RESTful service for a WPF(UI) Application. The UI sends
I have a WPF Path object which is created by reading nodes from a

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.