When is right time to load data in Prism [closed] - c#

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 3 years ago.
Improve this question
I need load data from database in Prism application and I don't know when.
Should I load data in constructor of view model ?
When is right time to load data in Prism ?

Should I load data in constructor of view model ?
If you use the ViewModelLocator avoid loading data in the constructor to not block the ui. If you create the view model yourself (i.e. somewhere in a background task), nothing's wrong with loading data in the constructor. In fact, I'd prefer that because you always have an initialized instance.
When is right time to load data in Prism ?
The above being said, the best bet is to implement INavigationAware and load your data in OnNavigatedTo (asynchronously, of course).

Related

INotifyPropertyChanged in a Model [closed]

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
In this tutorial INotifyPropertyChanged is in Model - not in ViewModel.
Is it correct and acceptable? What are standards ?
INotifyPropertyChanged is just an interface that provides functionality, it's not MVVM specific in any way. Classes generated by Linq to SQL or the like also usually implement it for example.
It is correct! You should raise PropertyChanged where you change the property (so in the model in your case). In other cases it might be in the view model but it can really be anywhere.
I think the confusion starts because the properties in the view model must raise the PropertyChanged event to update the UI. That does however not mean that the PropertyChanged event must have its origin in the view model.

Generating forms that use an MVC Web API [closed]

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

how to pre load a read only database in asp.net [closed]

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
I have used fastcgi when a process starts up and then executes and serves results to a client. I used to preload a readonly database into memory during the start up and then use that to server results. The advantage being the data gets loaded and prepared only once and is readily available.
How can this be accomplished in ASP.NET technology without using an external database technology like memcached etc?
It depends on how complicated the database is, but if I needed to do this I would load the database into the application cache as datatables, within the global.asax application_startup method.

How would you create a WPF control using the MVVM pattern? [closed]

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.

Design for ribbon-based applications [closed]

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.

Categories