列表框重叠后的列表框问题

时间:2011-07-26 11:27:43

标签: c# xaml windows-phone-7 listbox

我有一个listbox-news和listbox-comments,我试图表明:

  

列表框-消息

     
    

列表框-评论

  

但没有成功。 我有video of my problem,这是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>

1 个答案:

答案 0 :(得分:2)

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

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