KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
When databinding my xaml to some data I often use the "get" part of a property to do some logic. Like giving to sum of totals of a list or a check if something is positive. For example: public List<SomeClass> ListOfSomeClass{get;set;} public double SumOfSomeClass { get { return ListOfSomeClass.Sum(s => s.Totals); } } public bool SumPositive { get { if(SumOfSomeClass >= 0) return true; else return false; } } This way I can bind to SumPositive and SumOfSomeClass. Is this considered good practice? Even if it gets more complex than this? Or would it be better call a method and return the outcome? What about calls to another class or even a database?
Tags (comma-separated)
Save Edits
Cancel