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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:27:31+00:00 2026-06-05T10:27:31+00:00

I am using C# to create a WPF interface. The display shows current coordinates

  • 0

I am using C# to create a WPF interface. The display shows current coordinates of a moving object. What I am doing is trigger a thread on an interval which calls a function that checks the current position of the moving object.

Note: The function which checks the current position is called from other class(in a different .cs file) and my interface is in a another window, which is the main window.

How can I show the coordinates in the window interface? Is there a way to assign a variable which is initialized in one class(.cs) to another label toolbar in the interface(.xaml)?

  • 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-05T10:27:33+00:00Added an answer on June 5, 2026 at 10:27 am

    The simplest way to do this is to add a couple of TextBlocks (or TextBox if you prefer) and bind them to a property on a view model:

    <TextBlock Text="{Binding Path=XCord}" />
    

    The trick is that since you’re using a timer or a background thread, you have to synchronize the property change notifications so that they happen on your UI thread. So you could implement the XCord property like:

        public string XCoord
        {
            get { return _xcoord; }
            set
            {
                if(!Application.Current.Dispatcher.CheckAccess())
                {
                    Application.Current.Dispatcher
                        .BeginInvoke(new Action(() =>
                                                {
                                                    _xcoord = value;
                                                    NotifyPropertyChanged("XCoord");
                                                }));
                }
                else
                {
                    _xcoord = value;
                    NotifyPropertyChanged("XCoord");
                }
            }
        }
    

    This check’s with the Dispatcher to make sure you’re not trying to set the property from the wrong thread, and if you are, it uses BeginInvoke to do the work on the UI thread. That way, when the PropertyChanged event fires, and the binding attempts to read the value and change the UI it does so from the UI thread rather than the background thread.

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

Sidebar

Related Questions

I'm trying to create a simple media player interface using WPF. Though I'm a
Context: I'm creating a Login interface using WPF 4 which consists of two Label
Using WPF .NET 4.0 in VS2010 RTM: I can't create a fullscreen WPF popup.
I'm using WPF MVVM to create a wizard in Excel 2007. The wizard code
I want to create a ColumnSeries Bar Chart in WPF using C#. I shall
In a WPF application, I can create an inherited property by using the FrameworkPropertyMetadata:
I am trying to create Guava TreeMultimap object in scala, using TreeMultimap.create method, but
I would like create a very simple Paint application using MAF on WPF. The
Im using prism 4.0, wpf, I create RegionAdapter for devx DocumentGroup. I have a
I have an application which I am developing using WPF\Prism\MVVM. All is going well

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.