fsprojects / Avalonia.FuncUI

Develop cross-plattform GUI Applications using F# and Avalonia!
https://funcui.avaloniaui.net/
MIT License
889 stars 72 forks source link

Menu controls type error #398

Closed Kaiwen0418 closed 3 months ago

Kaiwen0418 commented 4 months ago

Hi, I was trying to use the menu control of FuncUI DSL, when I tried to run same code in doc, the Create method of MenuItem was reported undefined by IDE.

    MenuItem.Create [
        MenuItem.header "File"
    ]
    MenuItem.Create [
        MenuItem.header "Edit"
    ]
]

Menu.create [
  Menu.viewItems menuItems
]

Then I tried to use lower capital create like most of the other controls,

    MenuItem.create [
        MenuItem.header "File"
    ]
    MenuItem.create [
        MenuItem.header "Edit"
    ]
]

Menu.create [
  Menu.viewItems menuItems
]

I got the error Type mismatch. Expecting a  'Avalonia.FuncUI.Types.IView list' but given a 'Avalonia.FuncUI.Types.IView<MenuItem> list' from the Menu.viewItems menuItems line.

I am using net7.0 and Avalonia 11.0.2, and I am not sure if a version mismatch caused the error or if I didn't import the right dependency, it would be a great help if you could have a look at that.

Thanks!

Numpsy commented 4 months ago

There is a menu item example in the control catalog if that helps: https://github.com/fsprojects/Avalonia.FuncUI/blob/1d562ee04b5a5fd81a526e8e483c058b46391afd/src/Avalonia.FuncUI.ControlCatalog/Avalonia.FuncUI.ControlCatalog/Views/Tabs/WindowMenuDemo.fs#L26

I think all those create calls should be lower case though.

Kaiwen0418 commented 4 months ago

Thanks! That example works, and it will be good if someone can double-check the document page.