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

Break Issue in Net9.0 when using Custom Theme #10042

Open
umanagarajan12 opened this issue Nov 8, 2024 · 2 comments
Open

Break Issue in Net9.0 when using Custom Theme #10042

umanagarajan12 opened this issue Nov 8, 2024 · 2 comments
Assignees
Labels
Investigate Requires further investigation by the WPF team.

Comments

@umanagarajan12
Copy link

Description

We have updated all our projects to support .NET 9.0. As previously noted, our projects use a custom theme that functions well in .NET 8.0 and other frameworks but has been causing issues specifically in .NET 9.0.

We have logged this issue #10020 and received the recommendation: "The issue is due to a recent change to optimize DynamicResource usage (#5610). To prevent the crash, you can opt-out of this behavior by adding the following to your .csproj file:

<ItemGroup>
    <RuntimeHostConfigurationOption Include="Switch.System.Windows.Controls.DisableDynamicResourceOptimization" Value="true" />
</ItemGroup>

This solution has resolved the issue in some sample projects. However, we still encounter problems in other cases when using themes:

  1. In the SfScheduler control, adding an appointment that spans multiple days causes the app to freeze.
  2. In TimeSelector, switching themes leads to app freezing.

Both cases work without issues in .NET Core 8.0.

Note: We have also included <RuntimeHostConfigurationOption Include="Switch.System.Windows.Controls.DisableDynamicResourceOptimization" Value="true" /> in the .NET 9.0 project ItemGroup.

We’ve attached sample projects demonstrating this issue and video references for Issue replication.

Could you please investigate further?

Samples.zip
Video references.zip

@batzen
Copy link
Contributor

batzen commented Nov 9, 2024

That's a bug in LoopingSelector.Balance where this.additionalItemsCount = (int) Math.Round(this.ActualHeight * 1.5 / actualItemHeight); causes additionalItemsCount to become 2147483647 when actualItemHeight is 0 which is 0 because ItemHeight becomes 0 because the control style is set to null when the control is removed from the visual or logical tree.

For 2. the code in SfSkinManager that changes the theme should better be rewritten to first add the new theme resources and then remove the old one. Otherwise everything will receive a null style etc. before receiving the new resources.
That exactly what is done in the ThemeManager of ControlzEx for example to avoid such issues.

@harshit7962 Was anything changed in regards to removal of items from the visual or logical tree? Was the style always reset to null in those cases?

@harshit7962 harshit7962 added the Investigate Requires further investigation by the WPF team. label Nov 11, 2024
@dipeshmsft dipeshmsft self-assigned this Nov 12, 2024
@dipeshmsft
Copy link
Member

Was anything changed in regards to removal of items from the visual or logical tree? Was the style always reset to null in those cases?

@batzen, I don't think so we have done anything like that. I am taking further look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

4 participants