Repository navigation
Replies: 1 comment 2 replies
|
Your options are basically:
Style doesn't really do anything specific around this case: you've just got the normal tools which XAML and C# offer you. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Forgive me if I do not have the correct terminology. I have only been programming for a couple years.
When studying MVVM at first really just seemed like an infinitely complex way to restrain the capability of your application. Like a Rube Goldberg machine designed to cut my wobbly green c# programming sea legs out from under me.
Part of my difficulty was that I am working on an application that isnt quite your standard application connected to a database doing CRUD operations.
But after reading through Stylet Wiki and learning the viewmodel first approach seems much much simpler and makes TOTAL SENSE!....so an immense thank you to the people working on this project! I love it!!!!
With that out of the way, I have a small application that can display a host of different file types (html, pdf, tiff, txt, has a web browser etc...). What is displayed is determined by command line parameters passed to it on launch. In my root viewmodel I have a traditional menu system (file, edit help) and some buttons (Print, Save, Copy) along a top bar.
The production version (non MVVM) of this application has 6 code behind pages each with a dozen click events all performing the same actions. When I change something, I gotta go change it in 6 or more places.
With the awesomeness of Stylet, I can consolidate the actions of these controls into one place and reuse that code then pass in the viewing area (text file viewer control, pdf file viewer control, browser control etc..) into a user control as a child viewmodel!
Well, almost. My edit menu has "select all" and "copy". Actions which are to be performed on the specific control in the child viewmodel. I can Bind these menu choices to the ActiveItem (Active child viewmodel) but how would I command say the Telerik RadPdfViewer to use it's "selectall" extension method from a menu item all the way back up into the root viewmodel?
If an action is initiated from the view side with an event, you can grab the object sender and cast it into whatever I want and do something with it. But initiating something like "select all" text from the viewmodel side there is no handle I can grab to tell the control to do something. Below is my code.
Root View
Root ViewModel
Child View
Child ViewModel
All reactions