MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

Expander animation slower in class library

Open mouawadma opened this issue 1 year ago • 2 comments

Bug explanation

Here is a project example https://github.com/mouawadma/MDIXExpanderIssue

I am noticing that the expander animation is much slower when using it as part of a class library versus an independent application. Not sure why this is the case. I have attached two gifs to show it. Not sure what could be causing this?

Class Library

ClassLibrary

Independent App

IndepedentApp

Version

V5.1

mouawadma avatar Aug 22 '24 13:08 mouawadma

@mouawadma I feel like using a theming library inside of another library is quite the hassle. Adding the resource dictionary in the static constructor of your Window1.xaml works. However this has the drawback of not having intellisense for MDIX resources in your xaml.

public partial class Window1 : Window
{
	static Window1()
	{
		var resources = new ResourceDictionary
		{
			Source = new Uri("pack://application:,,,/TestingMDIX51Local;component/Theme.xaml", UriKind.RelativeOrAbsolute)
		};
		Application.Current.Resources.MergedDictionaries.Add(resources);
	}
	public Window1()
	{
		InitializeComponent();
	}

	private void InitializeMaterialDesign()
	{
		// Create dummy objects to force the MaterialDesign assemblies to be loaded
		// from this assembly, which causes the MaterialDesign assemblies to be searched
		// relative to this assembly's path. Otherwise, the MaterialDesign assemblies
		// are searched relative to Eclipse's path, so they're not found.
		var card = new Card();
	}
}

ExpanderTimeBug

Notice how your InitializeMaterialDesign() method is still there and needed as described by your comment. However the method isn't even called and to my knowledge it should be optimized out by the compiler. This is very odd.

corvinsz avatar Sep 01 '24 19:09 corvinsz

An external application calls our code and there are a lot of issues with it. I have no control over this and it has been found that dummy code is required to get everything loaded correctly.

All-in-all, I have to use a class library and I would like to use MDIX so I am short on options.

I tried your solution, and it seems to fix the issue of the slow expander, but makes the XAML horrible to use since there is not intellisense... wonder if there is a different way to resolve the issue? Why does my initial solution of setting the style in the code behind not work?

mouawadma avatar Nov 25 '24 18:11 mouawadma