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

The Archive Base Latest Questions

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

I am currently building a measurement unit convertion app for Windows Phone. After setting

  • 0

I am currently building a measurement unit convertion app for Windows Phone. After setting up my user interface I added data bindings to two textboxes, each display a measurement. (e.g. Fahrenheit <-> celsius)

So far, so good. However, when I deploy my app I run into a cyclic dependency. Whenever I update one value, the conversion function is called and the other unit is update. Hence, its value is set causing the conversion function to run again.

What can I do to avoid this dependancy? I guess its more of a conceptual thing than actual programming. Thanks

Example code

    private float _fahrenheit;
    private float _celsius;

    public float Fahrenheit {
        get { return _fahrenheit; }
        set { 
            _fahrenheit = value;
            FahrenheitToCelsius();
        }
    }

    public float Celsius
    {
        get { return _celsius; }
        set
        {
            _celsius = value;
            CelsiusToFahrenheit();
        }
    }

    private void CelsiusToFahrenheit()
    {
       Fahrenheit = _celsius * 1.8f + 32.0f;
    }

    private void FahrenheitToCelsius()
    {
        Celsius = ((_fahrenheit - 32.0f) * 5.0f) / 9.0f;
    }
  • 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-05T22:06:07+00:00Added an answer on June 5, 2026 at 10:06 pm

    I would pick one of them to be your base. The other one will always be a conversion of this. We do this with metric to imperial conversion for our app. All values are stored in metric but you can display either metric or imperial. If you were going to use Celsius as your base it would look something like this:

    private float _celsius;
    
    public float Fahrenheit {
        get { return _celsius * 1.8f + 32.0f }
        set 
        { 
            float cels = (((value - 32.0f) * 5.0f) / 9.0f);
            if (cels != _celsius)
            {
                _celsius = cels;
                TempPropertiesChanged();
            }
        }
    }
    
    public float Celsius
    {
        get { return _celsius; }
        set
        {
            if (value != _celsius)
            {
                _celsius = value;
                TempPropertiesChanged();
            }
        }
    }
    
    private void TempPropertiesChanged()
    {
       OnPropertyChanged("Fahrenheit");
       OnPropertyChanged("Celsius");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently building a Rails app, where a user can upload an mp3 and
I´m currently building an Android app, which tracks the user´s location. My aim is
Currently building a WPF app that will run in an environment where the user
I'm currently building an app that will play sounds. When a user starts a
Currently building an app that runs on mobile phones not related to the issue
I am currently building my project locally using MVC. The user enters some search
Some background I'm currently building a predominantly classic web app (rather than a single
I'm currently building a website with Django and want to host user bio style
Am currently building an app and I want the timer to start only when
I'm currently building a console app for a school project and I really need

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.