2013-01-22 289 views
1

我想創建一個無限longlistselector,但我的事件ItemRealized不會觸發。我創建視圖模型,所以我可以生成一個可觀察的集合,並且當我監視主類時,一切看起來都很好,我確信它不是空的,但是我的問題是我無法填充longlistselectorItemRealized事件不會觸發

<phone:PhoneApplicationPage.Resources> 
    <vm:GoogleView x:Key="viewModel"/>   
</phone:PhoneApplicationPage.Resources> 

longlistselector

  <phone:LongListSelector ItemRealized="m_ListBoxGoogle_ItemRealized" Name="m_ListGoogle" HorizontalAlignment="Center" Height="410" Margin="0,120,0,0"        
      ItemsSource="{Binding GoogleCollection}" 
      DataContext="{StaticResource viewModel}">    
      <phone:LongListSelector.ItemTemplate> 
        <DataTemplate> 
         <Button Tag="{Binding GoogleID}" Style="{StaticResource NoVisualTextButton }" toolkit:TiltEffect.IsTiltEnabled="True" Click="OnListBoxItemClick" Margin="-10,0,0,0"> 
          <StackPanel Orientation="Horizontal" Margin="0,3,0,0" Height="auto" Width="450"> 
           <Border BorderThickness="1" Width="62" Height="62" BorderBrush="#00aef0" Background="#00aef0"> 
            <Image Height="60" Width="60" Source="{Binding GoogleImagePath}"/> 
           </Border> 
           <StackPanel Width="350" HorizontalAlignment="Center" Margin="12,0,0,0" > 
            <TextBlock Text="{Binding GoogleDisplayName}" TextWrapping="NoWrap" Style="{StaticResource PanoramaItemTextStyle }" FontSize="24" /> 
            <TextBlock Text="{Binding GoogleObjectType}" TextWrapping="NoWrap" Style="{StaticResource PanoramaItemTextStyle }" FontSize="20" /> 
           </StackPanel> 
          </StackPanel> 
         </Button>   
       </DataTemplate> 
      </phone:LongListSelector.ItemTemplate> 
     </phone:LongListSelector> 

我真的卡住傢伙,請幫我

回答

2

嘗試這些東西,我相信它有約束力的問題:

  1. 調試並在GoogleView構造函數中放置一個斷點,並驗證它正在被實例化爲 。
  2. 如果正在實例化,請驗證綁定的數據是否存在於類中。
  3. 如果一切都實例化,嘗試綁定到集合作爲雙向綁定模式。
  4. 如果這不起作用,嘗試綁定到另一個控件中的數據以驗證事情是否正常工作。
+0

我很困惑一切都應該工作正常,但仍然一無所獲,也許今天不是我的 –

+1

天@radoslaf你可以把在GoogleView構造一個斷點,參見圖1)如果貝因poperly實例和2)如果數據實際上被放在那裏你期望的地方。你能否將其他數據綁定到可以確認數據的數據上? – OmegaMan

+0

所以我的問題是在綁定,謝謝 –