2013-03-14 49 views
0

我已經使用ItemsControl並將其添加到wrappanel中。命令沒有從ItemsControl中執行Silverlight 5 MVVM

<toolkit:WrapPanel Height="Auto" Width="Auto" Orientation="Horizontal" > 

    <ItemsControl ItemsSource="{Binding ParcelViewModel.FavoriteParcelImages}" Height="Auto" Width="Auto" > 
    <ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 

     <toolkit:WrapPanel Grid.Column="2" Grid.Row="1" Grid.RowSpan="3" Height="Auto" Width="Auto" Orientation="Horizontal" /> 

     </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 
    <ItemsControl.ItemTemplate> 
     <DataTemplate> 
     <Border BorderThickness="1" BorderBrush="LightGray" Margin="3" Height="Auto" Width="200" > 

      <StackPanel Orientation="Horizontal" Width="200"> 
      <Grid Width="200"> 
       <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="70"></ColumnDefinition> 
       <ColumnDefinition Width="*"></ColumnDefinition> 
       </Grid.ColumnDefinitions> 
       <StackPanel Grid.Row="0" Grid.Column="0" Height="100" HorizontalAlignment="Left"> 
       <!--<Image Source="/PropMgmt;component/Assets/Images/office-building-icon.png" Margin="0,5,0,0" Width="50" Height="50" />--> 
       <Image Source="{Binding DisplayImage.Source}" Height="50" Width="50"></Image> 

       <StackPanel Margin="15,0,0,0"> 
        <StackPanel Orientation="Horizontal"> 
        <Image Source="/PropMgmt;component/Assets/Images/circle_orange.png" Width="10" /> 
        <TextBlock Text="{Binding ReservedCount}" Margin="5,0,0,0"></TextBlock> 
        </StackPanel> 
        <StackPanel Orientation="Horizontal"> 
        <Image Source="/PropMgmt;component/Assets/Images/circle_green.png" Width="10" /> 
        <TextBlock Text="{Binding VaccantCount}" Margin="5,0,0,0"></TextBlock> 
        </StackPanel> 
        <StackPanel Orientation="Horizontal"> 
        <Image Source="/PropMgmt;component/Assets/Images/circle_red.png" Width="10" /> 
        <TextBlock Text="{Binding LeasedCount}" Margin="5,0,0,0"></TextBlock> 
        </StackPanel> 
       </StackPanel> 

       </StackPanel> 
       <StackPanel Grid.Row="0" Grid.Column="1"> 
       <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> 
       <TextBlock Text="{Binding Code}"></TextBlock> 
       <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> 
       <TextBlock Text="{Binding Title}"></TextBlock> 
       **<HyperlinkButton Content="{Binding Title}" Command="{Binding GetUnitListForParcel}" ></HyperlinkButton>** 

       <TextBlock Text="Year of Construction:" FontWeight="Bold"></TextBlock> 
       <TextBlock Text="{Binding Year_Of_Construction}"></TextBlock> 
       </StackPanel> 
      </Grid> 
      </StackPanel> 

     </Border> 
     </DataTemplate> 
    </ItemsControl.ItemTemplate> 
    </ItemsControl> 

</toolkit:WrapPanel> 

添加超鏈接按鈕裏面的DataTemplate。但我不明白爲什麼HyperlinkBut​​ton命令不工作?

請幫助..

回答

0

你需要改變你的綁定:

<HyperlinkButton Content="{Binding Title}" Command="{Binding YourViewModelName.GetUnitListForParcel, Source={StaticResource Locator}}" />