dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.4k stars 980 forks source link

In .NetCore project, Changes made in the Designer not being Serialized in the Designer.cs file. #11664

Open Sekar47 opened 3 months ago

Sekar47 commented 3 months ago

Environment

Edition - Windows 11 Enterprise Version - 23H2 OS build - 22631.3737 Visual Studio version - 17.10.4

.NET version

.Net 6,7,8

Did this work in a previous version of Visual Studio and/or previous .NET release?

No, it's not working in previous versions of netcore

Issue description

We are attempting to add items to a collection and serialize them in the designer class using the serializer class which inherits from CodeDomSerializer. However, this is not triggering whenever changes are made in the designer, resulting in the modifications not being serialized in the designer.cs file. Is this a limitation, or are there alternative solutions available? CustomControl_Tab (2) 1.zip

Steps to reproduce

1.In the Designer, Drag and Drop the CustomTabControl from ToolBox. 2.Click on AddTabItem option from Smart tag, you can add the tab items but it is not available in designer.cs file.

Diagnostics

No response

elachlan commented 3 months ago

@Olina-Zhang can your team please test?

Olina-Zhang commented 3 months ago

I cannot repro it in my side, after clicking AddTabItem in SmartTag, the toolStripTabItems code is available in designer.cs file: image

Sekar47 commented 3 months ago

Hi @Olina-Zhang , But see the toolStripTabItem's doesn't added in any parent control such as Form1 or customTabControl1. this is the issue, Actually, I wanted a case like if I add toolStripTabItem via SmartTag of the customTabControl then it'll need to directly be added in the header of the customTabControl1. is there any solution for achieving this case?

Olina-Zhang commented 3 months ago

Hi @Sekar47, created a sample app, please take a look: CustomControlSample.zip image

Sekar47 commented 2 months ago

Hi @Olina-Zhang ,

Thank you for the sample code provided. please refer the attached sample. in my case, we are using CodeDomSerializer in our TabControlHeaderSerializer class to handle header serialization for the CustomTabControl. CustomControl_Tab.2.1.zip

Could you please provide guidance or suggestions on how to properly use CodeDomSerializer in this scenario? Specifically, we are facing issues where changes made to the TabItem via the smart tag support are not reflected in the Designer.cs file.

Is there a recommended approach or best practices for using CodeDomSerializer to ensure that the designer updates correctly and reflects changes made in the UI? Any insights or examples on how to resolve this issue while continuing to use CodeDomSerializer would be greatly appreciated.

Thank you for your assistance.

Tanya-Solyanik commented 1 week ago

@LeafShi1 - I took a quick look at the sample project, it seems that DesignerAction panel is implemented correctly, only the serializer is not discovered on

    [ToolboxItem(false)]
    [DesignerSerializer(typeof(TabControlHeaderSerializer), typeof(CodeDomSerializer))]
    public class CustomTabControlHeader : ToolStrip, IHeader

Could you or your team investigate if anything is missing in the project or if this is a designer bug. If this is a designer bug, please move the issue to the designer repo.