I'm interested in approaches that avoids code in the code behind. In my opinion, there are some cases where code must be placed in the code behind. For example: I have a grid with an undefined count of columns. Columns can't be binded. So the easiest way would be to generate the columns in the code behind.
For this case, I can create a new class which inherits from the grid. This new class has a new binding property and code for the column binding. The code is separated in a custom class which can be used in the XAML. And then, I can easy bind the columns to my newly created property. And the view has no code behind.
Is it a good idea? How would you solve such (or similar) problems? Are there other ways to extract the code from the code behind?
Thanks.