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

Two custom control styles throw error #246

Open
opcodewriter opened this issue Feb 16, 2016 · 3 comments
Open

Two custom control styles throw error #246

opcodewriter opened this issue Feb 16, 2016 · 3 comments
Labels

Comments

@opcodewriter
Copy link

I'm trying to define two custom controls in the app (not in a library), but it gives me this error:

snip_20160216131715

In Resources/Styles.fayde I have two styles defining the template for two controls.
Note that if I remove MyControl2 style, it works, no error appears

Styles.fayde:

 <Style TargetType="controls:MyControl">   
  <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:MyControl">
                    <Grid Background="Blue" />       
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style TargetType="controls:MyControl2">   
  <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:MyControl2">
                    <Grid Background="Green" />       
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

The implementation is the same for both:

MyControl.ts:

import Control = Fayde.Controls.Control;
class MyControl extends Control {
    constructor() {
        super();
        this.DefaultStyleKey = MyControl;
    }
}
export = MyControl;

MyControl2.ts:

import Control = Fayde.Controls.Control;
class MyControl2 extends Control {
    constructor() {
        super();
        this.DefaultStyleKey = MyControl2;
    }
}
export = MyControl2;

In default.fap, I'm just using one control:
<controls:MyControl />

@opcodewriter
Copy link
Author

If I use MyControl2 instead of MyControl in default.fap, the error is now about MyControl which can't be loaded:

Uncaught (in promise) Error: Module name "Controls/MyControl" has not been loaded yet for context: _. Use require([])(…)

seems a problem with the way types are parsed and loaded from XAML styles?

@opcodewriter
Copy link
Author

adding these declarations in Styles.fayde makes it work:

<controls:MyControl x:Key="Dummy1" />
<controls:MyControl2 x:Key="Dummy2" />

@BSick7
Copy link
Member

BSick7 commented Feb 20, 2016

This is due to a tricky dependency resolution issue.

Every XAML document goes through 2 parsing passes. In pass 1, we scan for files that haven't been loaded. Once dependencies have been loaded asynchronously, we can proceed with pass 2 loading the markup.

Most likely, pass 1 needs to be updated to scan for Style TargetTypes.

@BSick7 BSick7 added the bug label Feb 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants