I am confused about where I put a dependency property when building a WPF application using the MVVM pattern. Does it go in the Model or the ViewModel?
Edit
After looking at early answers (thanks for those), I find that I am still confused, so I am giving more detail to help someone explain this to me.
I have a class called Station. It is used by surveyors and civil engineers to represent the length along a road. For the most part, a Station is just a double, but it has a few decorations. First off, the format is different. When distance along is greater than 100 feet, we add a + symbol as another way to format it. So 1234.56 feet down the road we might have Station 12+34.56. (I will skip the other decorations since this one is good enough for my point.)
Thus the logic for the special formatting lives in Station, a class in the Model. I want a TextBox in the View to take user input of 1234.56 and coerce it to a text value of "12+34.56". So I want a TextBox to give the user access to a value in the Model, so it needs to be a dependency property. (That is correct, isn't it?) But the business logic for coercing/parsing/understanding how to go back and forth between a TextBox and a Station should live in the Station class. (Right?)
Furthermore, I will later want to give the user the ability to set the station value by clicking on a graphical drawing of the road, including dynamically updating the value as the mouse moves and locking the value in upon issuing a data point. (Now you see why I tried to keep this brief.)
So is this not something that I would want to make a dependency property, especially with the dynamic data point possibly getting involved later? If not, how do I hook a text box item to a station using MVVM? (I really have researched this a lot before asking my question, but with no success.)
- Paul