Handling MenuItem Clicks for my Notepad app: Maintaining MVVM and Best Practice
I am making what is essentially a WPF notepad clone with menu items that for example sort and trim lines and so on. I have created utility classes with functions that take and return strings and basically are the main functionality. I have subclassed the main text box and created functions for it that essentially apply the utility functions to the selected text and update it. In my MainView.xaml.cs, I handle the menu items click by connecting it to the text box's functions. This doesn't feel right and I am wondering what I can do.
tl;dr I want to click a menu item in my notepad app that trims or sorts the currently selected text. What is the best way to achieve this.
Source Code: https://gist.github.com/MarioFares/21349c3a4bdfb27eca1fd5abf7680b2d
2 Replies
Looks ok. You do have some code duplication with theine splitting and joining, but other than that it looks fine. Actually, the first few of the helper methods are truly worthless, and you probably spent 10x the time writing those doc comments than writing the code, I don't see much benefit in exerting that much effort towards that.
Yeah the docs are very overkill. I added to them incrementally as I was testing the utility methods.