列表框重叠问题

本文关键字:问题 重叠 列表 | 更新日期: 2023-09-27 18:03:38

我有一个listbox-news和listbox-comments,我试图显示:

listbox-news

listbox-comments

但是没有成功。我有我的问题的视频,这里是xaml:

<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:delay="clr-namespace:Delay;assembly=PhonePerformance"
    xmlns:local="clr-namespace:iVk" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
    x:Class="iVk.newsDetail" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    >
  <!--LayoutRoot is the root grid where all page content is placed-->
  <Grid x:Name="LayoutRoot">
    <Grid Height="auto" Grid.Row="2" Grid.ColumnSpan="2" Margin="0,0,0,21" >
      <ListBox Style="{StaticResource ax3}" x:Name="detailnewslistBox">
        <ListBox.ItemTemplate>
          <DataTemplate>
            <local:FoodTemplateSelector Content="{Binding}">
              ...
            </local:FoodTemplateSelector>
          </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
          <ItemsPanelTemplate>
            <StackPanel/>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
      </ListBox>     
    </Grid>
    <Grid Height="auto" Margin="0,0,0,21" >
      <ListBox x:Name="comm_box" ItemsSource="{Binding}">
        <ListBox.ItemTemplate>
          <DataTemplate>
            <Grid Margin="{StaticResource PhoneTouchTargetOverhang}">
              <StackPanel VerticalAlignment="Top">
                <TextBlock Text="{Binding text}" Padding="11,0,0,0"/>
                <TextBlock x:Name="datetimetext" Text="{Binding date_time}"  Width="310">
                </TextBlock>
              </StackPanel>
            </Grid>
          </DataTemplate>
        </ListBox.ItemTemplate>
        <ListBox.ItemsPanel>
          <ItemsPanelTemplate>
            <StackPanel/>
          </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
      </ListBox>
    </Grid>
  </Grid>
  
</phone:PhoneApplicationPage>

列表框重叠问题

您需要在scrollViewer中包装两个列表框并禁用列表框的滚动:

<ScrollViewer VerticalScrollBarVisibility="Enabled">
    <StackPanel>
        <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" />
        <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" />
    </StackPanel>
</ScrollViewer>