Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# pivot控件中的列表框项不存在';我无法获得所有可用空间_C#_Windows Phone 7_Xaml_Layout - Fatal编程技术网

C# pivot控件中的列表框项不存在';我无法获得所有可用空间

C# pivot控件中的列表框项不存在';我无法获得所有可用空间,c#,windows-phone-7,xaml,layout,C#,Windows Phone 7,Xaml,Layout,我有一个简单的页面,里面有pivot控件和listbox,但我不能让listbox拉伸以获得所有可用空间 模板: <phone:PhoneApplicationPage.Resources> <converter:UserMessageConverter x:Key="MessageUserConverter" /> <DataTemplate x:Key="ItemTemplate"> <StackPanel Margi

我有一个简单的页面,里面有pivot控件和listbox,但我不能让listbox拉伸以获得所有可用空间

模板:

<phone:PhoneApplicationPage.Resources>
    <converter:UserMessageConverter x:Key="MessageUserConverter" />
    <DataTemplate x:Key="ItemTemplate">
        <StackPanel Margin="0,0,0,30">
            <TextBlock Text="{Binding Model.Text}" Style="{StaticResource PhoneTextExtraLargeStyle}"  FontSize="21.333" TextWrapping="Wrap" />
            <TextBlock Text="{Binding User, Converter={StaticResource MessageUserConverter}}" Margin="12,3,0,0" Style="{StaticResource PhoneTextSubtleStyle}" TextWrapping="Wrap" FontSize="18.667"/>
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="WindowsPhone.Application.ViewModel.MessageListViewModel">
        <ListBox ItemTemplate="{StaticResource ItemTemplate}" ItemsSource="{Binding Messages}" Background="Aqua">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
            <wi:Interaction.Triggers>
                <wi:EventTrigger EventName="SelectionChanged">
                    <wi:InvokeCommandAction Command="{Binding MessageSelectedCommand}" CommandParameter="{Binding SelectedItem, ElementName=MessageList}" />
                </wi:EventTrigger>
            </wi:Interaction.Triggers>
        </ListBox>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

支点:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <!--Pivot Control-->
<controls:Pivot Title="Messages &amp; Responses" ItemsSource="{Binding Pages}">
    <controls:Pivot.ItemTemplate>
        <DataTemplate>
            <helpers:DataTemplateSelector Content="{Binding}" />
        </DataTemplate>
    </controls:Pivot.ItemTemplate>
    <controls:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Title}" />
        </DataTemplate>
    </controls:Pivot.HeaderTemplate>
</controls:Pivot>
</Grid>


不是100%确定,但请尝试一下

 <Style TargetType="ListBoxItem">
      <Setter Property="HorizontalAlignment" Value="Stretch"/>
      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate>
                  <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
              </ControlTemplate>
          </Setter.Value>
      </Setter>
  </Style>


注意,但我认为
列表框
被拉伸到整个父容器,但父容器没有。为什么水彩盒在页面的中央,而不在左侧或顶部?请尝试制作相同的应用程序,但不使用模板化的
透视图
,可能它会将您推向正确的方向,您会发现问题所在

不幸的是,相同的问题如果我使用非模板化透视图,效果很好,问题只会在我使用透视图项目模板时发生