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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:59:37+00:00 2026-05-26T22:59:37+00:00

I’m very new to WPF. I’m currently doing a code to detect joints coordinate

  • 0

I’m very new to WPF. I’m currently doing a code to detect joints coordinate using the Kinect SDK and displaying on a simple textbox in WPF. The code to detect joints are in a private void Window_Loaded(object sender, RoutedEventArgs e) method. To display the coordinates, I used DataContext. Without further ado, let’s just see the XAML code:

<Window x:Class="Prototype.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="480" Width="640">
<Grid>
    <TextBox x:Name="coordinateText" Width="150" Height="20" Margin="441,409,27,12" Text="{Binding Path=xInfo}"/>

</Grid>

And this is my C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Research.Kinect.Nui;
using Coding4Fun.Kinect.Wpf;

namespace Prototype
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //this.DataContext = new Coordinate { xInfo = "5" };
        }

        Runtime nui = new Runtime();

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = new Coordinate { xInfo = "5" };
            nui.Initialize(RuntimeOptions.UseSkeletalTracking); //code for detecting joints

            //some code for detecting joints

        }

        public class Coordinate
        {
             public string xInfo { get; set; }
             public string yInfo { get; set; }
             public string zInfo { get; set; }
        }
    }
 }

The thing is the information will not be loaded in the textbox if this.DataContext = new Coordinate { xInfo = “5” }; is not placed in the MainWindow. I have to put it in the Window_Loaded method. Any solutions?

  • 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-26T22:59:37+00:00Added an answer on May 26, 2026 at 10:59 pm

    As Coder323 said When window is loaded you need tell WPF TextBox that the Value of the variable xInfo is changed so you should use INotifyPropertyChanged in your Model Class

    then where ever you change theValue of your Object it will pick up the changed Value… also
    Just Set the DataContext=myCordinate in the Window Constructor then, make my cordinate a variable in the window class.

        public class Coordinate : INotifyPropertyChanged
        {
             private string xInfo;
             public string XInfo {
                                    get{retun value}; 
                                    set{
                                         xInfo=Value;
                                         FirePropertyChanged("XInfo")
                                       } 
                                 }
    
    
             public event PropertyChangedEventHandler PropertyChanged;
             protected void FirePropertyChanged(string propertyName)
             {
                var handler = PropertyChanged;
                if (handler != null)
                {
                    handler.Invoke(this, new PropertyChangedEventArgs(propertyName));
                }
             }
    
       }
    

    Do this for other properties and now you can set the value of myCordinate.XInfo=”what ever you like” in any event it will notify to your view that the respective property has changed..

    I am putting my complete solution here

    My Coordinate class

    public class Coordinates : INotifyPropertyChanged
    {
        private string xInfo;
        #region Implementation of INotifyPropertyChanged
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public string XInfo
        {
            get { return xInfo; }
            set
            {
                xInfo = value;
                InvokePropertyChanged(new PropertyChangedEventArgs("XInfo"));
            }
        }
    
        public void InvokePropertyChanged(PropertyChangedEventArgs e)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, e);
        }
    
        #endregion
    }
    

    My Xaml

    <Window x:Class="TestApp.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" Loaded="Window_Loaded">
    <Grid>
        <TextBox Text="{Binding Path=XInfo}" Height="30" Widht="100"></TextBox>
    </Grid>
    

    My Xaml.cs

    namespace TestApp
    {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Coordinates myCoordinates;
        public MainWindow()
        {
            myCoordinates=new Coordinates();
            this.DataContext = myCoordinates;
            InitializeComponent();
        }
    
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            myCoordinates.XInfo = "Acbd";
        }
    }
    

    }

    And yes this test Project i made… is working

    This might Help 🙂

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.