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

I'm considering the following: I have some data stream which I'd like to protect
I'm considering integrating some D3D code I have with WPF via the new D3DImage
I have been considering taking the plunge and installing Linux on my Playstation 3.
Logging can get complicated, quickly. Considering that you have some code, how do you
I have this small code library that I'm considering releasing into Open Source. I
I'm considering using Annotations to define my Hibernate mappings but have run into a
We are considering a move from SVN to Mercurial, and have encountered a stumbling
Trying to develop using MVVM: I have this Csla.PropertyStatus control that is created in
I am really stuck trying to implement RIA Services with MVVM and a crud
I've been considering how you would write a business application in only F# with

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.