How do I access my view from within my view model with Prism? - prism

I'm using Prism for MVVM. In my main window, I have a ribbon menu, and a tab control which shows all of my views. I want to be able to dynamically update my ribbon with contextual commands based on which view is currently selected. The binding is more complicated than just a simple list of commands (each command has an icon, subcommands, different sizes, grouping, etc.), so I think I need to somehow get a reference to my ribbon control within the main view model so I can programatically add/configure my ribbon commands. How do I get a reference to the view from within the view model?

How do I get a reference to the view from within the view model?
Use i:Interaction.Behaviors to attach the Loaded event of your view to a command on your view model and pass the view as parameter.
And then, get mad while writing the test suites for this. If I were you, I'd do everything else before I force view types into the view model...

Related

MFC:CDHtmlDialog Purpose/Usages to open other views?

I was thinking of writing a new app where a users selects an option of what procedure they want to perform and the view changes to that until done then goes back to the main menu. I came across CDHtmlDialog and looked like a nice easy way to add a nice looking menu using html. But I wonder if that is the purpose of that class? Can I set it up so when a button or graphic link is clicked it changes out the view to another one (I would need to use traditional things like CTreeView with CListView with a splitter) or is it more for staying within the HTML world?
Thanks.
From the MSDN MSDN documentation
CDHtmlDialog Class is used to create dialog boxes that use HTML rather than dialog resources to implement their user interface.
From what I can gather from your post, I think you should consider SDI application using view classes that you want. To switch views on the command you do not need a splitter window. A static splitter is used to display a number of views in a different part of the splitter simultaneously.

Buttons in a view in Dynamics 365

I am new with Dynamics 365 and are not sure of how I can achieve this.
I am looking into having some buttons in a view.
Maybe a view isn't the best way of doing it, but what I want to do is to have a list of records connected to the logged in user (similar to a view)
But on each row/record I want to have multiple buttons. These buttons can be like 'Complete' (Changes status on task and updates the view) , 'Send email'(Starts a workflow) and so on.
What are some of the ways of doing this? Either with Javascript/C#/plugin or something else.
You cannot add buttons in views/subgrids directly.
That’s when we add ribbon/command bar buttons using Ribbon workbench usually.
Create a Workflow Short Cut Ribbon Button (No Code Solution!)
Update:
There is a PowerApps Components Framework (PCF - preview) coming out soon, then we can build custom grid control with the layout/buttons we want.
This can be achieved with RibbonWorkbench. My answer does not differ much with #arun vinoth answer but just added few explanation lines.
https://ribbonworkbench.uservoice.com/knowledgebase/articles/132235-create-a-workflow-short-cut-ribbon-button-no-code
If you look at view below where I have selected number of contact and then I have a Button at top "Nominieren" which is shown and clicking on it will perform whatever action is needed.
There will be java-script on click of button, from Java script you could call Action or workflow or perform operation in Java script itself.
Link for Adding new Button : https://community.dynamics.com/crm/b/crmtipsfromadeveloper/archive/2017/07/26/know-how-add-a-ribbon-button-using-ribbon-workbench
Now when you look at image below I have no contact selected and it does not show button on Ribbon.
It might be possible. I haven't tried this but you can write JavaScript for a view column now (since CRM 2016).
If you go to a view you can double click on a view column to view its properties. There are two properties you might be interested in:
Web Resource
Function
Here's a link to an MS page that explains how to use these options to add an icon. It might be possible to create a clickable button which uses CRM's WebApi to perform some actions: Docs # Microsoft

How to find the editor for multi view controllers

I am very new to xcode, got stuck in finding the editor to modify the code when created multiple view controllers. Whenever I click on any of the view controllers, I only see same editor contents and cant move to the others for coding.
I searched the web and stackoverflow but could not find a clear guideline on how to manage the editors for multiple view contollers. I have attached a snapshot.
You don’t “find” code. You create it.
When you drag a view controller into the storyboard, it has the default class of UIViewController. It is up to you to make a new code file where you subclass UIViewController, and then to go back to your storyboard and change the view controller to that subclass in the Identity inspector.

Cocoa how to handle multiple views?

I'm have done some development on iOS using Storyboards. Now I'm building on app for Mac OS X and it seems that an equivalent for Storyboards does not exists.
For instance, I'm need to build some kind of wizard, which contains four different windows or views (step 1 to 4).
Currently I've created one Window xib (the standard MainMenu.xib), containing a window with the first view, and three other custom views. Using this approach, I can create outlets and actions, making me able to change the contentView of my window, e.g. when clicking an button. This seems as a fair solution, and my views are all grouped cleanly inside a single xib. But this also cause that the logic for all the view should be handled by the same File's Owner, right? For instance saving the settings on each step and controlling the interaction between the different views.
How is the preferred way to handle a situation like this? Should I instead create four different windows, and maybe in four different xib-files? If you know an sample project somewhere from the internet showing how to handle multiple windows, please give me a hint.
You can make use of the NSViewController class for this purpose. Each view controller will be responsible of loading a xib associated with it and all logic associated with the views can go inside the controllers (Same as in iOS). The MainMenu.xib can now load appropriate views after initialising the required view controllers.
Here is a sample app for your reference.
https://developer.apple.com/library/mac/samplecode/ViewController/Introduction/Intro.html
In xcode, go to File->New->New File
Add an objective C class and set it to subclass of "NSViewController".
This will itself create yourController.h, yourController.m and yourController.xib.
Now you can keep your view and its controller class seperate.

How to separate the application bar buttons for each PanaramaItem in the Windowsphone?

I have totally two PanaramaItems in my PanaramaPage of my windows phone application. I need to show two ApplicationBarItems in the first Panrama item and 3 Application Bar items in the second PanaramaItem.. Is there any to do this Xaml page... I don't want to do anything through code behind... Can any one help me ?
I'm pretty sure in this case you'll have to programmatically manipulate the toolbar for each PanoramaItem. If you don't want to do it in code behind and are using a mvvm framework there are ways to do it without coupling the ViewModel to the View. You could create a service that both items could access to manipulate the toolbar. In Caliburn Micro each VM has a reference to the View and manipulation could be done that way. Further in CM an IResult can be created and fired off in the OnActivate for each item.

Resources