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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:22:22+00:00 2026-05-10T22:22:22+00:00

Considering you have an MVVM Architecture in WPF like Josh Smith’s examples How would

  • 0

Considering you have an MVVM Architecture in WPF like Josh Smith’s examples

How would you implement two properties ‘synced’ that update eachother? I have a Price property, and a PriceVatInclusive property in my model.

-When the Price changes, I want to see the Vat inclusive price to automatically be ‘Price * 1.21’.

-Vice versa, when the PriceVatInclusive changes, I want the Price to be ‘PriceVatInclusive / 1.21’

Any ideas on that?

And what if your model is a Entity framework entiry? You can’t use the approach above then… no? Should you put calculating code in the ViewMOdel or … ?

  • 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. 2026-05-10T22:22:23+00:00Added an answer on May 10, 2026 at 10:22 pm

    One way:

        public class Sample : INotifyPropertyChanged     {         private const double Multiplier = 1.21;         #region Fields         private double price;         private double vat;         #endregion          #region Properties         public double Price         {             get { return price; }             set             {                 if (price == value) return;                 price = value;                 OnPropertyChanged(new PropertyChangedEventArgs('Price'));                 Vat = Price * Multiplier;             }         }          public double Vat         {             get { return vat; }             set             {                 if (vat == value) return;                 vat = value;                 OnPropertyChanged(new PropertyChangedEventArgs('Vat'));                 Price = Vat / Multiplier;             }         }         #endregion          #region INotifyPropertyChanged Members         protected void OnPropertyChanged(PropertyChangedEventArgs e)         {             PropertyChangedEventHandler ev = PropertyChanged;             if (ev != null)             {                 ev(this, e);             }         }         public event PropertyChangedEventHandler PropertyChanged;          #endregion     } 

    If you can derive from DependencyObject, you can use Dependency Properties.

    public class Sample : DependencyObject {     private const double Multiplier = 1.21;      public static readonly DependencyProperty VatProperty =         DependencyProperty.Register('Vat', typeof(double), typeof(Sample),          new PropertyMetadata(VatPropertyChanged));      public static readonly DependencyProperty PriceProperty =         DependencyProperty.Register('Price', typeof(double), typeof(Sample),          new PropertyMetadata(PricePropertyChanged));      private static void VatPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)     {         Sample sample = obj as Sample;         sample.Price = sample.Vat / Multiplier;     }      private static void PricePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)     {         Sample sample = obj as Sample;         sample.Vat = sample.Price * Multiplier;     }      #region Properties     public double Price     {         get { return (double)GetValue(PriceProperty); }         set { SetValue(PriceProperty, value); }     }      public double Vat     {         get { return (double)GetValue(VatProperty); }         set { SetValue(VatProperty, value); }     }     #endregion } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Considering I have two smartphones, A and B. If I am holding smartphone A,
Considering I have two arrays for example: String[] array1 = new String[10]; int[] array2=
Considering the most popular MVC/MVVM client-side patterns (like Knockout.js , Angular.js , Ember.js ,
Considering I have a continuous joint distribution of two independent normal random variables (let's
Possible Duplicate: Determine if two rectangles overlap each other? Considering I have 2 squares
I have been considering the problems arising with user authentication, using sessions/cookies and the
Considering that I have a Schema named SBST I want to find all empty
I have a question considering a program that stimulates a stack (not using any
I have the following doubt. I am considering the option to have html tags
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce 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.