I am trying to hook up an ICommand on the model to a button within the ItemTemplate of a Pivot control.
To get a link to the parent model from within the ItemTemplate I usually use ElementName specifying the Name I provided for the xaml page.
This works when I use a ListBox to contain the items but not a pivot control.
Does any one have any ideas or come across this problem before?
Just noticed that if I define the PivotItems in xaml the Binding works. So it is only failing when I am dynamically populating the Pivot control.
UPDATE : OK So I’m beat with this now. I have linked the event to the models ICommand in the views code behind (nasty) and I’m going to look @ this later. I will post my solution here once I have found it but any help would be great.
This is a know problem in
Silverlight 3. Since,WP7uses it right now, you will face the same thing with it as well.To fix that, wrap your
DataTemplatecontent that you put in yourItemTemplateinto aUserControl.Look into this question for further details.
WP7: Why does a ListBox.ItemsPanel break my ElementName data binding?