Have you ever considered how WPF does navigation between pages with MVVM?
You’ve got your View and ViewModel, which present a single page, or some area in your page. But what’s the guideline to actually change the content of the page to a new View and ViewModel?
I think MVVM doesn’t really explain that. Which is strange because in almost any application you’d have multiple pages and some sort of flow.
And what about wizard-type applications? What is supposed to happen when I click that “Next” button?
Recently I worked on an ASP.NET Core project and I discovered Microsoft did a very good job implementing navigation with MVC. It’s extremely intuitive and easy to understand.
So after mulling over this for a while, I did the only reasonable thing anyone in my situation would do. I went ahead and built a framework in WPF to implement navigation like in ASP.Net Core.
Recently I was dealing with a couple of bugs in C# regarding timeout behavior. The solutions were pretty interesting so I decided to share them.
In WPF you can do everything in many different ways. It’s not always clear what is better. For example, we got many different ways to reuse a UI component. We can use Templates, User controls, Custom controls, ViewModels with data templates and so on. So which is better? The answer is obvious. Always use user controls!
Just kidding 🙂 The answer is always different, depending on your specific scenario. And a lot of times, it’s far from obvious what’s better. Just for the fun of it, let’s explore one of those scenarios where it’s not so clear which is better.
A long time ago, on my first programming job I had a design problem that I couldn’t solve.
This problem haunted me. The reason was that it seemed so simple, and yet I couldn’t find a good solution for it.
Eventually I did a huge refactor, but instead of solving it correctly I simply changed one problem to another.
Recently, years later, in a different company, I came up with that great solution I was after.
So besides telling you I’m thinking about code from years ago way too much, I want to share with you my exciting great solution. Continue reading
Some time ago I had to do a Theming infrastructure for the application in my company. Our application was pretty big with hundreds or maybe thousands of resources in XAML. Let me tell you something: Structuring those resources with Merged Dictionaries was a huge pain in my butt. I had to learn all WPF’s problems the hard way. Don’t repeat my mistakes, read this post carefully before restructuring your XAML resource files.
We’ll go through the problems and eventually I promise to provide some great solutions which will give you a head start. Continue reading
Let’s say we want to change the looks of all buttons in our application.
We want them to have a black background and text inside to have white foreground.
WPF gives us a Style infrastructure to do just this. But, as often happens with WPF, we can achieve this in many different and confusing ways.
Let’s make some order out of the chaos.
My name is Michael, welcome to my blog.
I’m 33, live in Israel, working as a .Net and C++ software developer, interested in everything about programming.
I wanted a place to share my bit of knowledge with the community.
Keep up with the blog and I hope to get your interest.