Closed chasihle closed 3 years ago
They work the same as anything else with a Command
property:
<MenuItem Command="{s:Action SomeMethodOnTheViewModel}"/>
Can you please post the code you're having trouble with?
Attached are the View and ShellViewModel files. When I run It now I get the following error
Stylet.Xaml.ActionNotSetException: 'View.ActionTarget not set on control System.Windows.Controls.MenuItem Header:Create Customer Items.Count:0 (method CreatCust()). This probably means the control hasn't inherited it from a parent, e.g. because a ContextMenu or Popup sits in the visual tree. You will need so set 's:View.ActionTarget' explicitly. See the wiki section "Actions" for more details.'
I hacked that code into a project which I could actually run, SmallBusCustMgtWPF.zip, and the menu works fine.
Please provide a minimal reproducible sample which I can run and which reproduces your issue. Thanks!
Hey, Still doesn't work for me. I get the same error I included in my previous email. I've attached a zip of the entire solution and the local SQL DB. This isso simple and it's kicking my butt [Uploading StyletSmallBusinessCustMgmnt.zip…]() :)
So clicking "new customer" in the zip I uploaded fails for you?
Can you try and create a minimal repro? https://stackoverflow.com/help/minimal-reproducible-example
(Also, that zip you linked is just a link to this issue -- there's no zip there I'm afraid)
Hey Antony, I was going through my solution this morning commenting out anything related to DB access, removing some class files related to things non UI and of course it still failed. So before I zipped it up to send to you I took your project and added in the DB access and other class files and everything works like a charm. Go figure. I don’t know what the differences are, I can’t see any. It seems that under .NetCore something must get corrupted and by creating a new project and adding in the same objects it will work.
Anyway, I don’t know if you want me to still send you my original solution, I will if you want .
Thanks very much for your help
Charlie
Sent from C. Ihle's iPhone 704-439-6270
On Oct 22, 2020, at 4:20 PM, Antony Male notifications@github.com wrote:
(Also, that zip you linked is just a link to that issue -- there's no zip there I'm afraid)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
One thing I did change was I removed the assignment of the DataContext from the code behind: Stylet takes care of instantiating and assigning the ViewModel. Can youssee whether that was the cause?
I'm not sure how it could have been, as that would have been overridden by Stylet straight away, but it's worth checking.
Antony, I still get the error in my original project even after removing DataContext from the code behind
Charlie
Sent from C. Ihle's iPhone 704-439-6270
On Oct 22, 2020, at 6:29 PM, Antony Male notifications@github.com wrote:
One thing I did change was I removed the assignment of the DataContext from the code behind: Stylet takes care of instantiating and assigning the ViewModel. Can youssee whether that was the cause?
I'm not sure how it could have been, as that would have been overridden by Stylet straight away, but it's worth checking.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
The other possibility is that the project I put together targets netcoreapp: does yours target framework?
Yes, the project is netcore 3.1. I’ve noticed that with my Core projects as I try different things, add/remove packages etc.. it’s almost like something gets corrupted. I’ll create a new project add in the existing items from the problem project and it will work. That’s what I just did with the project you hacked together and it’s been working fine.
Sent from C. Ihle's iPhone 704-439-6270
On Oct 23, 2020, at 1:32 PM, Antony Male notifications@github.com wrote:
The other possibility is that the project I put together targets netcoreapp: does yours target framework?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Closing as I don't think there's anything else to do here. Please re-open if necessary. Thanks!
Hi, Do you have examples for implementing menus? I can't bind a menu item to a ViewModel method. In Caliburn.Micro I just had to name the menu item the same as the method in ShellView but doesn't work in Stylet. Any help you can provide would be greatly appreciated.
Thanks, Charlie