0

我使用过 ItemsControl 并将其添加到 wrappanel 中。

<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 上的命令不起作用?

请帮忙..

4

1 回答 1

0

你需要改变你的绑定:

<HyperlinkButton Content="{Binding Title}" Command="{Binding YourViewModelName.GetUnitListForParcel, Source={StaticResource Locator}}" />
于 2013-03-14T07:39:49.307 回答