开发者

WP7 - Problem with DataTemplate on emulator but not On Blend

This is the code:

      <ItemsControl x:Name="ContactsControl" ItemsSource="{Binding Contacts}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                    <Grid>
                        <TextBlock Text="{Binding ElementName=ContactsControl, Path=DataContext.PageName}" />
                    </Grid>
                </Border>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

On the TextBlock I want to get date from the ItemsControl data context, so I use ElementName and in the 'Path' I use Path=DataContext.PageName.

So, On Blend I can see th开发者_StackOverflowe data on the TextBlock as it should be, but when I run the emulator I cant see the data... Why is it?

I'm working with VS2010 and Blend 4.

Thanks.


You are binding an items control to a list of Contacts. Traditionally you will then bind the textblock to a property of the class contained in the list. Why are you binding to another control and then bringing datacontext into the equation? Doesn't seem like something you normally do with a list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜