tags:

views:

15

answers:

1

I'd like to bind selected elements from a Grid to text boxes on a different page.

Can this be done?

A: 

If you mean completely separate pages, those screens only exist separately. When your "text box page" appears the previous "grid page" no longer exists. If it could be done my answer would be "Don't do it" as you would wind up with separate pages tightly bound to each other. That is considered a bad practice.

The latest Silverlight practices say that data should be shared via Models and View Models that live longer than the screens (lookup Silverlight MVVM patterns on Google). View Models are basically a place to move your code-behind to. The aim is to leave your XAML pages virtually code free.

Basically you want your screens to share common data. In this case that would include your current selection in a list of data items (you don't actually care if it was a grid that did the actual choosing).

The "grid screen" is bound to the data model to get its data source for the grid and also has its current selected item bound to an item in the data model. The same Model (or View Model) is bound to your "text box page" when it is created. The text boxes on that page are bound to the results previously stored in the data model.

One downside is that all bindable properties in data model/view Models have to be Dependancy Properties. If you do not make them bindable you get no error, just no data.

Enough already