Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How do you structure your project for ribbon based projects, when using WPF?
I use Microsoft's Ribbon control and I wonder if I should have a single
view for the main app, but two separate view models one for the ribbon
and another for the window part below the ribbon.
You are asking a very subjective question... I'm actually surprised that it hasn't been closed yet (we have many keen question closers on this site). The answer to your question of course depends on what the application does, its size, the developer's style and preference of programming, etc.
I personally just prefer to hardcode the controls into my Ribbon rather than generating them from a view model and templates. It does make the code page large, but I'd rather have that then be confused as to what goes where and when.
I generally prefer to simply have one property of type BassViewModel in my MainViewModel class and that is data bound to a ContentControl in 'the window part below the Ribbon as you call it. Then I just set this property to the relevant view model dependant upon the users' view selection in the Ribbon.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have tried many options for a long time and that is the last one that comes to my mind, so I will try to ask:
I am trying to develop an MVVM project in WPF and I have downloaded a ready-to-use WPF control (GMap.NET). However, this control is not prepared to use it in MVVM and I am a newbie in that, so I do not want to modify a source code on my own. The control requires to set many parameters (not accessible through XAML, so I cannot simply bind them), and call some functions on control object. So here goes my question:
How can I access a WPF control instance from any place from the code and manage it from there?
Particularly, I want to access a View element from ViewModel part and I know that it brakes the pattern, but I have no idea how to avoid it and I am running out of time.
Hard to say without knowing the concrete control. But in general, I see 2 options for make such a control MVVM conform:
Subclass the control and add dependency properties so it can be used in XAML
Create a "container control" that wraps the unMVVMable control and provides the required dependency properties.
However, if the API of the control is complex and has not only properties, but also some methods, it may be pragmatic do break MVVM here. MVVM is not the only way to separate GUI related logic from the view. You could abstract the used functions with an interface and use the interface within your view model for example.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am developing an interface that customizes and generates forms for customers to use on their own site. When a user logs in to the interface, he can create a form, add or remove fields from existing forms, and the system will generate the file.
I want to know what's the best approach for doing this. Making these forms independent and just use HTML/Javascript? or have them part of the overall MVC solution inside a Views folder so it can have server side code?
Probabily the best way is not to store the entire form, but having some metadata that describe the forms, then generate the gui dynamically. There are many ways to doing this, it basically depends on your skill, and your specifics, personally im developing something similar right now and i chose Angular2.
Here an example:
https://angular.io/docs/ts/latest/cookbook/dynamic-form.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Here's what I'm trying to do:
I have a main form and I added a UserControl named menu to it. Here's how it looks:
http://prntscr.com/a5dx0e
Now what I want is: when I select an item from the menu, the content below the menu will change without loading another form.
I could do that but the user would see a window disappearing and another appearing and that's kinda ugly.
What I really want is to replace the content based on the menu item clicked.
The best way I found was to create multiple UserControls and then just replace them with the right one. Is this a good idea or are there any better solutions?
Please note that I'm a starter in C# and I'm looking for the easiest solution.
Use the tab control and hide the tab header. Control the navigation amongst the pages programmatically when user clicks a menu. I've used this technique successfully in the past.
Choices,
hide/reveal panels (ways to collect/group all of the controls you are hiding revealing now)
Use a multi-tab control
Use an MDI (multi document interface) control
Use multiple forms, but display the new one first, then hide the prior one.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have created a wizard using the winforms tab control (hiding the tabs and using "previous" and "next" buttons). Each page of the wizard is a separate user control, but they all update a common object. I need the ability to move forward or backward and persist the data at each step, even skipping steps if they are optional.
I'm tempted to create a "global" object for the wizard that all user controls can access, but I'm certain that is not a best practice. What is the best approach for this scenario?
Since your modified Tab control resides on a form, simply make the "data" object as a member of the form class.
That way you'll have access to it from anywhere within the form, thus you can pass a reference to it to the custom UserControls whenever you navigate the wizard.
Cheers
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
So I'm having trobule figuring out the best way to use the MVVM pattern while creating a WPF control dynamically within
my code. Would this even make sense or is it better to avoid the MVVM pattern all together?
If it does make sense then please share code examples of the view model.
In general, if you're using MVVM, controls will only be created "dynamically" in response to the data changing. If you have an ItemsControl bound to a collection, for example, the controls to represent the items will automatically be created for you.
If you're talking about making a custom control in general, custom controls are really "pure view", so MVVM doens't really make sense in this scenario. The main goal of creating a custom control is to build it in a way so that it can be used by code developed with MVVM, which typically means building the control with proper Dependency Properties (so data binding works properly), etc.