Skip to content

Problems importing embedded styles using @import and changing the class name at runtime #102

@aguerrieri82

Description

@aguerrieri82

(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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions