13
votes
Accepted
Filter Collection by Multiple Criteria
You can build the LINQ query in several steps by appending new where clauses
...
8
votes
Accepted
MVVM - ObservableCollection & Entity Framework DbContext
An EF DbContext is an IDisposable object that should be as short-lived as possible.
There are a number of problems with this:
<...
8
votes
Accepted
Winform, with a workaround to avoid dependencies
If you start thinking with code, you will almost always end up doing bad things. Why? Because it is not natural. OK, no more preaching and let's get to work.
Review of Your Code
I apologize for ...
7
votes
Accepted
WPF Mvvm async function ViewModel
General
Your model should not return an ObservableCollection because that collection should be used only if its change notification ability is needed (e.g. with ...
7
votes
Accepted
ViewModels Mediator with multiple generic callbacks
I don't feel like you should override + and -. Fine, it makes the syntax cuter, but it makes your code much less readable for ...
6
votes
Accepted
Data Model for a Memory Game
Design review or code review?
Well, in real-world projects we communicate the design in its own way first, not just say “here’s code that implements my design.” I would like to see a paragraph ...
6
votes
5
votes
Accepted
MVVM Navigation WPF
One of the basic principals of MVVM is, that the view model doesn't know the view. My experience is, that this principal can be (and should be) applied for the most cases. However, it is possible that ...
5
votes
ViewModels Mediator with multiple generic callbacks
You should not be calling it a dictionary because you changed the expected behaviour of the IDictionary interface. The MSDN clearly states that the getter of the ...
5
votes
ViewModels Mediator with multiple generic callbacks
I fully agree with TopinFrassi and t3chb0t.
Some other points
The MultiDictionary and the AddableHashSet are not required and ...
5
votes
ViewModels Mediator with multiple generic callbacks
Don't test whether a HashSet contains a key if you want to remove it:
if(list.Contains(value)) {
list.Remove(value);
}
...
5
votes
Accepted
MVVM pattern in Xamarin login form
No, it's not correct.
View-model shouldn't contain anything related to view. It means LoginViewModel shouldn't contain references on progress bar and label. ...
5
votes
Accepted
5
votes
Accepted
5
votes
MVVM model letting the user select a directory in a testable manner
Review
You always instantiate inner dialogs for both platforms, even though one will never be called. Your platform will not change at runtime. Use the Lazy pattern to only instantiate the required ...
4
votes
AsyncCommand using MVVM and WPF
I realized that the question is quite old, but still seems to have some relevance. I guess people feel attracted, because they expect to find a usable asynchronous ...
4
votes
Converting models into a list of ViewModels
I don't know what to say more then:
make it an extension and return an IEnumerable<T> instead by using linq
do you mean something like this?
...
4
votes
MP3 tag Project in MVVM style
Avoid using regions or use them only sparingly. Grouping fields or constructors doesn't make any sense and doesn't help anyone.
Avoid the this keyword. It's rarely ...
4
votes
ListBox with a dynamic number of TextBox elements
There is not much to improve...
additional to the points from Heslacher:
a) That code:
...
4
votes
ListBox with a dynamic number of TextBox elements
ExcludedPath
If the value of the properties aren't changed you won't need to raise the PropertyChangedEvent so a simple check like
...
4
votes
CommandBinding refresh on parameter changed
OK several years later and looking back I now know what I was doing wrong
this is a misuse of the command parameter
the command parameter is not a variable that you pass into the command on ...
4
votes
Accepted
4
votes
Accepted
Testing async method call from constructor
Trying to load the data asynchronously in the constructor is a bad idea and in my opinion goes against what the constructor is for.
Constructors cannot be async, and asynchronous initialization can ...
4
votes
Addition Program using wpf through MVVM
Some quick remarks:
Give things proper names. "Model.cs" is a bad name for a class, and in your case it is even the name of a namespace. Microsoft has Naming Guidelines; please follow them.
Same for ...
4
votes
Accepted
MVVM model letting the user select a directory in a testable manner
Additionally to the great answer of dfhwze, I'll provide an alternative implementation that includes some of the suggestions.
Primary, I would implement each case separatly and create / dispose the ...
4
votes
Accepted
WPF MVVM ColorLister with navigation
Preface
There is a lot to review. This review is focused on the parts that are not related to the View or ViewModel.
Note: You have also edited the question concurrently with me making this review ...
3
votes
Accepted
CommandBinding refresh on parameter changed
I'm having to break MVVM by having the view tell the VM command that its execution has changed because the command binding doesn't seem to refresh on the parameter changing.
The fundamental problem ...
3
votes
Transitioning a NavigationPane to use MVVM
Sometimes I feel like some of the SO answers are people looking at the UWP code and thinking it's WPF and put in their two cents without thinking...
And yet there are only two lines related directly ...
3
votes
Accepted
Catching exception inside model
There is nothing inherently wrong with catching exceptions in viewmodel. The rule of the thumb is that you catch exceptions at level where you can handle them. Sometimes this level is viewmodel level.
...
3
votes
Accepted
Invoke model logic in one UserControl from view-model in another UserControl without violating MVVM
You do not pass this value through views. There is no reason to make your views responsible for creating view models. For example this:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
mvvm × 179c# × 142
wpf × 90
xaml × 20
android × 12
.net × 11
design-patterns × 10
swift × 10
dependency-injection × 10
object-oriented × 9
java × 7
javascript × 6
kotlin × 6
xamarin × 6
databinding × 6
beginner × 5
entity-framework × 5
async-await × 5
sqlite × 5
unit-testing × 4
ios × 4
authentication × 4
rubberduck × 4
uwp × 4
performance × 3