Silverlight 5.0 Prism 4.0 Designer

Topics: Prism v4 - Silverlight 4
May 28, 2012 at 12:09 PM

hello all
I'm creating a silverlight 5.0 application based on the Prism 4.0
I'm trying to implement MVVM
a part of 'application is a designer
which is to create objects dynamically
that must be viewed and modified in view
these items should be recorded in a database
and it must be possible to reload
I was trying to figure out how best to structure the 'application
sorry but I find it difficult to apply in this case MVVM
you have any advice?
any links?
thank you very much

 
 
 
Developer
May 28, 2012 at 10:00 PM

Hi,

As far as I know, currently there is no specific guidance in Prism about the handling of data from a database.

Regarding the MVVM implementation, as mentioned in the Prism documentation (Implementing the MVVM Pattern chapter):

Typically, the model represents the client-side domain model for the application. It can define data structures based
on the application's data model and any supporting business and validation logic. The model may also include the code
to support data access and caching, though typically a separate data repository or service is employed for this. Often,
the model and data access layer are generated as part of a data access or service strategy, such as the ADO.NET
Entity Framework, WCF Data Services, or WCF RIA Services.

Hence it's probably that your model classes may be used in conjunction with a service or a repository which will encapsulate data access and caching.

Also, you could check the Stock Trader RI application as a reference that illustrates a common baseline architecture.

Additionally, you may find the following threads interesting, where a similar topic are discussed:

Regards,

Agustin Adami
http://blogs.southworks.net/aadami

May 28, 2012 at 10:44 PM

thanks for your answer
I and 'very useful thanks
I'm sorry
in addition to this
I need to create objects (such as text ... images ... video ...)
on a canvas
what 's the best structure to do with Prism and MVVM
I have to create such as a TextBlock in the Canvas
example:
dim t as new texblock
mycanvasdesigner.Children.Add (t)
is more correct in the view or create this viewmodel?
the view is simple using codebehind
but I was not clean
considers that what is created in this canvas should be saved in a database
and which then must be reloaded if necessary
what 's the best structure for this type of application do you think?
considers that this is the first application in which I'm implementing Prism and MVVM
thank you very much

 
 
 
May 28, 2012 at 10:44 PM

thanks for your answer
I and 'very useful thanks
I'm sorry
in addition to this
I need to create objects (such as text ... images ... video ...)
on a canvas
what 's the best structure to do with Prism and MVVM
I have to create such as a TextBlock in the Canvas
example:
dim t as new texblock
mycanvasdesigner.Children.Add (t)
is more correct in the view or create this viewmodel?
the view is simple using codebehind
but I was not clean
considers that what is created in this canvas should be saved in a database
and which then must be reloaded if necessary
what 's the best structure for this type of application do you think?
considers that this is the first application in which I'm implementing Prism and MVVM
thank you very much

 
 
 
Developer
May 29, 2012 at 7:37 PM

Hi,

As far as I know a possible implementation for this particular scenario using the MVVM approach could be for example to define an ObservableCollection of FrameworkElements in your ViewModel. This ViewModel could consume a service that contains the logic to retrieve / create each FrameworkElement with its corresponding data.

Then you could bind your ViewModel's ObservableCollection property to the ItemsSource property of your container control which you will use to display the elements in the view.

The problem you may find is that Canvas is a "primitive container" and does not have an ItemsSource property to bind to. The Panel.Children property is read only, and it wont allow you to directly bind it to the ViewModel's ObservableCollection. Hence, as far as I know this cannot be directly achieved.

As a workaround for this, for example you could customize an ItemsControl to look like a Canvas by changing the ItemsPanel property to Canvas.

You could find more information about this in the following thread:

Also, I believe you could find the following threads interesting, as I believe they could be related to your scenario:

Also, as this particular implementation is not strictly related to Prism, I believe you could find more information on how to achieve it for example in the Silverlight forums.

I hope you find this handy,

Agustin Adami
http://blogs.southworks.net/aadami

May 29, 2012 at 8:21 PM

thanks
thanks
thanks
I immediately start to analyze your response
congratulations for your willingness
thanks