Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: It's not possible to edit/create KryptonContextMenu's items using the designer on .NET #2100

Open
ICloneableX opened this issue Jan 25, 2025 · 7 comments
Labels
area:designer All issues related to the designer. area:toolkit All issues related to the toolkit components. bug Something isn't working version:100 All things to do with V100.
Milestone

Comments

@ICloneableX
Copy link

Describe the bug
After adding a KryptonContextMenu to the form, it's not possible to make changes to its items through the designer if you're using .NET (it works on .NET Framework).

To Reproduce

  1. Add a KryptonContextMenu to the form.
  2. Go to the Properties window and look for the Items property.
  3. Try to click to open the context menu Items editor.
  4. The button to open the Items editor doesn't show up.

Screenshots

Image

On .NET Framework, the button is there and clicking it opens the Items editor normally:

Image

Desktop:

  • OS: Windows 10
  • Framework/.NET Version: [.NET 8.0]
  • Toolkit Version: 90.24.11.317 and 100.25.1.20-beta

Additional context
I understand that this might be related to the designer issues with .NET and that there is a proposed workaround but...
a. That workaround is not really practical.
b. The other issues you can sort of get around them but this one makes using KryptonContextMenu impossible.
d. I don't fully understand the root cause behind these designer issues but if I'm not mistaken, this one should work because other editors (like the KryptonPage Collection Editor, for example) work fine. Unless I'm missing something that makes it different.

@ICloneableX ICloneableX added the bug Something isn't working label Jan 25, 2025
@Smurf-IV
Copy link
Member

Q: Why is the workaround not practical? It's only for the designer, not for the binary builds.

@ICloneableX
Copy link
Author

ICloneableX commented Jan 25, 2025

@Smurf-IV

Unless I misunderstood the workaround, it's basically just adding a .NET Framework version to the target frameworks, which prevents you from referencing any packages that are not supported by .NET Framework, right? Or did I miss something about how to apply the workaround?

@Smurf-IV
Copy link
Member

Smurf-IV commented Jan 25, 2025

it's basically just adding a .NET Framework version to the target frameworks

Correct.

which prevents you from referencing any packages that are not supported by .NET Framework, right?

It will prevent them from resolving when attempting to build, but not from being added to the project.
If you do not want it to even try and build then you can add filter inside the csproj, But I just ignore the error targets and set the build output to be of a certain type in the options within Visual studio project bar.
e.g.

Image

And in CI (Dev-Ops) just set the build target in the option being passed to the build command

@PWagner1 PWagner1 added area:designer All issues related to the designer. area:toolkit All issues related to the toolkit components. version:100 All things to do with V100. labels Jan 26, 2025
@PWagner1 PWagner1 added this to the Version 100 milestone Jan 26, 2025
@PWagner1
Copy link
Contributor

it's basically just adding a .NET Framework version to the target frameworks

Correct.

which prevents you from referencing any packages that are not supported by .NET Framework, right?

It will prevent them from resolving when attempting to build, but not from being added to the project. If you do not want it to even try and build then you can add filter inside the csproj, But I just ignore the error targets and set the build output to be of a certain type in the options within Visual studio project bar. e.g.

Image

And in CI (Dev-Ops) just set the build target in the option being passed to the build command

@Smurf-IV

I'll update the docs with this info

@ICloneableX
Copy link
Author

@Smurf-IV @PWagner1

Sorry, I'm not sure I follow. Say, I have a simple project with the package Microsoft.EntityFrameworkCore, and I have a form with some code that's not supported by .NET Framework. For example:

List<int> list = new();
string path = Path.Join(@"C:\", "Windows");
int[] arr = [1, 2, 3];

Is there a way to target .NET Framework to use the designer for Krypton controls while being able to build and test the project?

As soon as I replace <TargetFramework>net8.0-windows</TargetFramework> with <TargetFrameworks>net48;net8.0-windows</TargetFrameworks>, the project no longer compiles and sooner or later, the designer will refuse to load due to the compiler errors. Changing the build output doesn't make a difference either.

Here's a sample project to demonstrate this:

WinFormsApp1.zip

What am I missing?

@PWagner1
Copy link
Contributor

PWagner1 commented Jan 26, 2025

@Smurf-IV @PWagner1

Sorry, I'm not sure I follow. Say, I have a simple project with the package Microsoft.EntityFrameworkCore, and I have a form with some code that's not supported by .NET Framework. For example:

List list = new();
string path = Path.Join(@"C:", "Windows");
int[] arr = [1, 2, 3];
Is there a way to target .NET Framework to use the designer for Krypton controls while being able to build and test the project?

As soon as I replace <TargetFramework>net8.0-windows</TargetFramework> with <TargetFrameworks>net48;net8.0-windows</TargetFrameworks>, the project no longer compiles and sooner or later, the designer will refuse to load due to the compiler errors. Changing the build output doesn't make a difference either.

Here's a sample project to demonstrate this:

WinFormsApp1.zip

What am I missing?

Hi @ICloneableX

Have you tried #if definitions? i.e.

#if NET8_0_OR_GREATER
            List<int> list = new();
            string path = Path.Join(@"C:\", "Windows");
            int[] arr = [1, 2, 3];
#endif

This way, that code block will only work/compile for >= .NET 8

Also, you can try something like:

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-windows'">
  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
</ItemGroup>

<ItemGroup>
  <PackageReference Include="Krypton.Navigator" Version="90.24.11.317" />
</ItemGroup>

@ICloneableX
Copy link
Author

ICloneableX commented Jan 29, 2025

@PWagner1

Unfortunately, none of that is practical except for very simple projects.

Please don't get me wrong. I know that this isn't your fault and that most of it is on Microsoft and its new designer that's causing a lot of issues. I do appreciate all the great work that you guys are doing.

For now, I have some workarounds that I use to mitigate some of these issues. They're still quite annoying. Haha! But they're at least more practical in real-life scenarios. Here are some examples off the top of my head:

Problem Workaround
Can't use action lists for quick actions Use the Properties window instead
Can't click to switch tabs in KryptonNavigator Change the SelectedPage property on the Properties window
Cant copy and paste KryptonDataGridView with columns Recreate the columns on the target grid (wastes time but I'm not sure if there's a better alternative)
Can't add controls to KryptonGroupBox, KryptonGroup, KryptonHeaderGroup, or pretty much any control with a child panel (this is a big one) I use the .Designer.cs file to add a panel inside the child panel (e.g., kryptonGroupBox1.Panel.Controls.Add(myPanel);) and then I can add controls to it (well, not directly. I have to add the controls outside and then move them to the panel inside the group)
Can't use the Document Explorer Navigate the controls manually and try not to create too complex UI's. Use a UserControl when possible.
Can't use KryptonContextMenu at all For now, I use ContextMenuStrip instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:designer All issues related to the designer. area:toolkit All issues related to the toolkit components. bug Something isn't working version:100 All things to do with V100.
Projects
None yet
Development

No branches or pull requests

3 participants