Prevent Visual Studio load a custom partial class as a designer

.net, c#, visual-studio, windows-forms-designer, winforms

Solution

As an option add a dummy class decorated by `[DesignerCategory("")]`at the beginning of your file. This limits the behavior of `DesignerCategory` to the first class which the designer tries to load.

Not elegant but working:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1
{
    [System.ComponentModel.DesignerCategory("")]
    public class Dummy { }

    public partial class Form1
    {
    }
}

Problem

In Visual Studio, there are lot of designer editors, Windows Forms, XAML, Installer, and others. Sometimes, I create a new source code as partial class (custom) to separate the logic. For example: - Partial code only: class Form1 : Windows.Forms.Form → Form1.cs - Partial Designer only: partial class Form1 : Form → Form1.Designer.cs - Partial class (custom) : partial class form1 : Form → Form.Print.cs In this last, I include print only methods and properties, and then, when I double click this file on Solution Explorer, always open the designer, instead of code editor, of course, I try use F7 or right-click to do that, but when I share the project with co-workers, it becomes a problem. Anyone know how to avoid this behavior? Maybe a class attribute!?

Original source

Related problems