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

styled property not working on UserControl #15572

Closed
touhidurrr opened this issue May 1, 2024 · 3 comments
Closed

styled property not working on UserControl #15572

touhidurrr opened this issue May 1, 2024 · 3 comments
Labels

Comments

@touhidurrr
Copy link

touhidurrr commented May 1, 2024

Describe the bug

same as above.

To Reproduce

// LoginView.axaml.cs
public static readonly StyledProperty<bool> TriggerProperty = AvaloniaProperty.Register<LoginView, bool>("Trigger");

public bool Trigger
{
    get => GetValue(TriggerProperty);
    set => SetValue(TriggerProperty, value);
}

// LoginView.axaml

image

As you can see there is no error or warning. However... When I try to build it....

0>LoginView.axaml(22,35): Error AVLN3000 : Unable to find the parent scope for AvaloniaProperty lookup Line 22, position 35.

I tried many things. But could not fix this issue.

Expected behavior

Build succeeds.

Avalonia version

11.1.0-beta2

OS

Windows

Additional context

Autocompletions work but build fails.

@touhidurrr touhidurrr added the bug label May 1, 2024
@maxkatz6
Copy link
Member

maxkatz6 commented May 1, 2024

You can only use TemplateBinding inside of the actual template. In your UserControl code you don't have any templates (from what I can see here).

So, you probably need:

IsVisible="{Binding $parent[ns:LoginView].Trigger}"

where "ns:LogingView" - is this user control.

Alternatively, you can add x:Name on your LoginView root element, and then use named control binding "{Binding #MyLoginView.Trigger}"

@touhidurrr
Copy link
Author

@maxkatz6 this is off-topic but can you answer this also... In login view after login is done I want to set trigger to false and make login invisible. How can I do it?

@timunie
Copy link
Contributor

timunie commented May 2, 2024

I'd swap views tbh. See Avalonia.Spamples for a simple Navigation sample

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

3 participants