<!--实现绑定的图片等信息 ListBox水平滚动-->
          <Grid>
              <Grid.Resources>
                  <Style x:Key="horizontalListBoxStyle" TargetType="ListBox">
                      <Setter Property="ItemsPanel">
                          <Setter.Value>
                              <ItemsPanelTemplate>
                                  <StackPanel Orientation="Horizontal"
            VerticalAlignment="Center"
            HorizontalAlignment="Center"/>
                              </ItemsPanelTemplate>
                          </Setter.Value>
                      </Setter>
                  </Style> 
              </Grid.Resources>
 
              <ListBox Height="auto" Name="imglist1"  HorizontalContentAlignment="Left" 
                ScrollViewer.HorizontalScrollBarVisibility="Auto"  
                       Style="{StaticResource horizontalListBoxStyle}">
                  <ListBox.ItemTemplate>
                      <DataTemplate>
                          <Grid>
                              <Grid.RowDefinitions>
                                  <RowDefinition Height="auto"></RowDefinition>
                                  <RowDefinition Height="60"></RowDefinition>
                                  <RowDefinition Height="*"></RowDefinition>
                              </Grid.RowDefinitions>
 
                              <Image Name="imgShow" Source="{Binding Path}" Tag="{Binding Id}" Grid.Row="0" Width="420" Height="400" Margin="30,30,30,30" Stretch="Fill" MouseLeftButtonUp="imgShow_MouseLeftButtonUp"></Image>
 
                              <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="1">
                                  <Button Name="btnZan" Tag="{Binding Id}" Content="赞" Height="70" Width="150" FontSize="26" Margin="20,0,10,0" Click="btnZan_Click"></Button>
                                  <Button Name="btnCai" Tag="{Binding Id}" Content="踩" Height="70" Width="150" FontSize="26" Margin="10,0,20,0" Click="btnCai_Click"></Button>
                              </StackPanel>
 
                              <Grid Grid.Row="2" ></Grid>
 
                          </Grid>
                      </DataTemplate>
                  </ListBox.ItemTemplate>
              </ListBox>
 
          </Grid>

相关文章:

  • 2021-11-30
  • 2021-12-02
  • 2022-12-23
  • 2021-12-15
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-07-05
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案