This is a migrated thread and some comments may be shown as answers.

Binding problems with control in grid row

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel Billingsley
Top achievements
Rank 1
Daniel Billingsley asked on 15 Jul 2010, 07:31 PM
This may be more of a general silverlight question/issue, but here goes...

I have a property in my ViewModel... let's say it's ReplyButtonVisibility.

I have a button ReplyButton near the top of my page with its Visibility bound to that property.  Works perfectly.

Now, in each row of the grid, I also have a button ReplyButton2 that I'd like to bind to the same VM property.  I can't get it to work.  I realize the DataContext of the grid is going to be its data source, so I don't expect to use the same binding as the ReplyButton that's not part of the grid.

So, I thought I'd be clever and use element binding to just bind the row button's Visibility to the Visibility of the top ReplyButton.  No go.  The row visibility of the buttons in the rows never changes.

So, I guess the first and maybe easiest question is why the visibility of the button in each row didn't update when bound to the Visibility property of the main ReplyButton (not in the grid)?

Secondly, is there a binding syntax that would allow me to get to the LayoutRoot's DataContext (the ViewModel) from within the row? 

1 Answer, 1 is accepted

Sort by
0
Daniel Billingsley
Top achievements
Rank 1
answered on 15 Jul 2010, 08:08 PM
I added the following to the row button's binding, and it's working as expected now.

Source={StaticResource mainVM}
Tags
GridView
Asked by
Daniel Billingsley
Top achievements
Rank 1
Answers by
Daniel Billingsley
Top achievements
Rank 1
Share this question
or