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

DataTemplateView may not work in some cases #396

Open
hxYuki opened this issue Feb 3, 2024 · 2 comments
Open

DataTemplateView may not work in some cases #396

hxYuki opened this issue Feb 3, 2024 · 2 comments

Comments

@hxYuki
Copy link

hxYuki commented Feb 3, 2024

For example, MenuItemTemplate from FluentAvalonia.NavigationView. The viewFunc can be triggered, but the view is not applied.
You have to use builtin FuncDataTemplate instead.

It seems that it's because of NavigationView requiring NavigationViewItem as top element in template. And it doesn't fit the restriction.

Is there a different behavior from FuncDataTemplate or something I did wrong?

// this works
FuncDataTemplate<string>(fun value scope ->
    let nvi = NavigationViewItem()
    nvi.Content <- value + "!!!"

    nvi)

// this doesn't work
DataTemplateView<_, _>.create (fun item ->
    create<NavigationViewItem> [] (fun nv -> nv.Content <- (item + "!!!"))) // my wrapper calling `init` and ViewBuilder for third party controls
@JaggerJo
Copy link
Member

JaggerJo commented Feb 4, 2024

DataTemplateView<_, _> can you fill in the types here ind make sure the template matches the data type?

@hxYuki
Copy link
Author

hxYuki commented Feb 5, 2024

Yhea, it is DataTemplateView<string, IView<NavigationViewItem>>.
This doesn't work either. And with a break point set I can see the template is called twice with item being "a". Which just like returning an element other than NavigationViewItem in FuncDataTemplate, the template is discarded samely.
(With source [ "a"; "b"; "c" ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants