How to create a service, passing it the server connection parameters and that it would periodically update the tables, and the main program in c # wpf would send requests and take tables to it. And how to bind the grid from xaml to the table of this service, and let the service be engaged in data processing.

How to do this? wcf and the like has not done.

    1 answer 1

    Grid is a View, and if there is a View, then there must be a model. I can offer something like the following solution:


    • Do without "service". Service is a very informal concept and too general for pattern-based programming.
    • Enter in your application some factory of models, say YYYModelFactory . It is this factory that will take in the parameters of the database connection.
    • It is clear that the factory returns some model, which is already on the database. In this model, it is quite reasonable to introduce methods like Update, etc., whose logic is local to the model. Alternatively, of course, it is possible to construct a new model for each Update type request, but this approach is generally considered harmful.
    • A model is some ObservableCollection in terms of MVVM. So, you can fasten a GridView on it in a completely native way (read about MVVM, if you still are not aware). Any update to a properly organized model will be automatically projected onto the View if the model is set as some BindingElement.
    • What is a minus? - Asen2