alexcurtisdev / ViewToViewModelSwitcherNetCore

# View To ViewModel Switcher
MIT License
0 stars 0 forks source link

Buttons to change the file as listed in the readme/Extension description are not visible? #2

Open DevTKSS opened 1 week ago

DevTKSS commented 1 week ago

The Buttons shown in Readme and Extension Description are not visible in Visual Studio 2022 (Community) in WPF Project Tryed different Templates:

alexcurtisdev commented 1 week ago

Please could you outline the steps required to setup a project with one of these templates please? I can then try this myself. When you say the buttons are not visible, are any?(Right click context menu/in the 'View' drop down)

Can you verify there is a corresponding named file to the one you are in i.e. if you're looking at 'NotificationsViewModel.cs' there's a corresponding 'NotificationsView.xaml'? This is the bases of the logic.

DevTKSS commented 1 week ago

Since I am just starting with WPF and Mvvm, the steps are quite just creating the template (in WPF App I did add a File Named it with ending ViewModel) and right click like it was told and also trying with view. My VS UI Language is German, if there is any incapability of VS between the Languages. The Files are Named of course in Englisch like everything in programming.

DevTKSS commented 1 week ago

the German Menu Button corrensonding to the English "View" is named "Ansicht" if your tool is searching for display name property on that. From my experience doing extensions for an other Application, it should be the internal name for this things. But if its just that it should at least be present in right click menu, what would also be no problem to me, since I am rarly using the top menu bar except for clean up project or rebuild

alexcurtisdev commented 1 week ago

I've just installed the German language pack and it still seems to work, here's my setup. Is there anything you notice that's much different from your setup? (can ignore the folders in my image - it's just the files it cares about) image

DevTKSS commented 1 week ago

Default WPF App template used, added folders, views and viewmodels: image Screenshot 2024-11-09 223113 image

Additional enchancement Idea for if the Button would be there: In the WPF-UI Template, which provides a nice Fluent appearance and is having a Gallery app in Microsoft Store, all Views are default named with Page/Window on the end, so it would be nice, if you might could add a Page Ending for the View section for that. Also the default setted name on creating a page in a regular WPF-App is named including "Page" by Default.

But that enchancement would only take place if there would be a Button in the vs UI in general ;)

alexcurtisdev commented 1 week ago

Thanks for the pictures, really useful! From these I can say the button wouldn't appear in image 1 and 3, the first because whatever context menu that counts as for Visual Studio I haven't coded it to work for(will likely add this in a update in the near future!) At the time/typically I'm switching between view/view model when looking at the files so I was only testing right clicking inside the file directly(instead of the solution window). The reason 3 doesn't show is because your in the xaml.cs file instead of the view/xaml itself. Again I could add this in the future but when I originally wrote this didn't consider this as I rarely need to go to the xaml.cs. Makes sense that you might/would want this to work.

I'm unsure why the button doesn't show for your image 2, since this should work and does on mine(no longer in german language though).

Do the buttons shows when your on a 'Page1View.xaml'? and you right click the code itself? likewise with the 'Page1ViewModel.cs' and have you tried restarting VS since installing the extension?.

I agree with your points, I'd like to have the names customisable in the future instead of having it hardcoded to looking for view.xaml and viewmodel.cs.

DevTKSS commented 1 week ago

what do you mean with "The reason 3 doesn't show is because your in the xaml.cs file instead of the view/xaml itself"? As far as I have seen in all wpf templates I did try (for seeing the capabilitys of each one) and also uno, each one is having the codebehind xaml.cs file right behind the xaml. But the ViewModel is in the ViewModels folder above this views folder if you might have a close look. So... I was expecting it would change from e.g. Page1View.xaml or at least Page1View.xaml.cs to the Page1ViewModel.cs file. no, the button is no where showing up at all. I did restart it yes, but I was a bit curious about the fact that it did not wanted me to close the solution and just installed. All other extensions waited until the vs instance has closed before installing the vsix packet of it

alexcurtisdev commented 1 week ago

Regarding the 'Reason 3 point' I meant because in that example you are in the 'Page1View.xaml.cs' file and not in the Page1View.xaml file this is why it won't be showing. It specifically is coded to work with the view.xaml and viewmodel.cs not the view.xaml.cs. I can add this in the future to make this also work. When I was coding it I didn't consider this as it wasn't a daily need with my job(rarely go into the xaml.cs so didn't consider it).

The restart thing is a bit odd, I might try that tomorrow and see if it does require a restart.

I copied a part of your structure and tested(when on the view.xaml and viewmodel.cs image image image

DevTKSS commented 1 week ago

Hm... 1 difference might be that your MainPage is on root and not in the views/viewModels folder struct Windows...

I dont know, which criteria your tool is searching for... Just the name or also Interfaces or inherited class? If you do, that might be a reasonšŸ¤”

Is it correct that only installing the extension is needed or is there also a nuget additional to be added to the project? Did just the extension... Never developed a extension for VS...