Problems importing embedded styles using @import and changing the class name at runtime
(I apologies for my english) I took a look into the source, and it builds the resource name based on assembly name.
- I can have multiple assembly with the same style name (and it's quite common in a multi-library application with some convention), and it picks up the first one matching (example) MyProject.Lib1 ┖─ Style.css MyProject.Lib2 ┖─ Style.css
- The resource name in .net is built based on the default namespace rather than assembly name (90% is the same, but in my case wasn't)
I made a little edit in
GetEmbeddedResourceName, so if the source starts with #, he interprets it as full qualified resource name
protected virtual string GetEmbeddedResourceName(string source, Assembly assembly)
{
if (source.StartsWith("#"))
return source.Substring(1);
return GetEmbeddedResourcePrefix(assembly) + source.Replace("\\", ".").Replace("/", ".");
}
If the class name is bound and it changes during the runtime, some unpredictable behaviour occurs. I didn't have the time to full investigate the issue, but in my case was an essential feature: one of the main reason for using a css-like approch was to overcome the trigger's limitation in case of multiple condictions (es. IsMouseOver (from control) && !IsActive (from view model) and use the class to define the actual state of the view (es. "selected active default" on a list item)
P.S anyway congraturation for the huge work you made and the coding quality. I think to build an expression parser (maybe using roslyin) helping to express multiple conditions in triggers
Hi @aguerrieri82 , first, thank you for using XamlCSS and your kind words!
I see the problem you're having. Using some form of special uri would solve this indeed.
But instead of using the #-symbol to denote embedded resources, I would prefer some sort of more standard-ish url like res://MyProject.Lib1.Style.css.
I will try to make time the next days to provide a solution to this.
PS: I'm also no native-speaker, and your english is good, no need to apologize! :)