如何在枢轴中设置列表框

时间:2011-08-18 11:39:16

标签: windows-phone-7

我的问题是我如何设置具有itemtemplate的listbox,它也是pivot的itemteplate .i不知道这样做但是需要我的项目。另一个是如何设置pivot头。我试图做那样的事情

      <controls:Pivot Height="779" Name="m" >
      <controls:Pivot.Background>
        <ImageBrush ImageSource="/WindowsPhoneApplication7;component     
        /Images/S.jpeg" />
    </controls:Pivot.Background>
    <!--<controls:PivotItem Name="all" >-->
    <controls:Pivot.ItemTemplate>
        <DataTemplate>
            <ListBox  Height="450" HorizontalAlignment="Stretch" Margin="8,6,0,0" Name="listBox1" VerticalAlignment="Stretch"   Background="#00537393" Width="445" >
                <ListBox.ItemTemplate >
                    <DataTemplate >

                        <Border  BorderBrush="Black" CornerRadius="8" BorderThickness="1" HorizontalAlignment="Stretch" Name="border">

                            <Grid   HorizontalAlignment="Stretch" Name="grid1" VerticalAlignment="Stretch">

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0*" />
                                    <RowDefinition Height="100*" />
                                </Grid.RowDefinitions>
                                <Image Height="78" HorizontalAlignment="Left" Margin="13,12,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="92" Grid.Row="1" Source="{Binding ImageSource}" />
                                <TextBlock Foreground="White" Height="80" HorizontalAlignment="Left" Margin="111,12,0,0" Name="textBlock1" Text="{Binding Title}" VerticalAlignment="Top" Width="280" TextWrapping="Wrap" Grid.Row="1" />
                                <Image Grid.Row="1" Height="75" HorizontalAlignment="Left" Margin="380,12,0,0" Name="image2" Stretch="Fill" VerticalAlignment="Top" Width="73"  Source="/WindowsPhoneApplication7;component/Images/appbar.transport.play.rest.png" />

                                <TextBlock  Foreground="White" Grid.Row="1" Height="20" HorizontalAlignment="Left" Margin="111,88,0,0" Name="textBlock2" Text="{Binding date}" VerticalAlignment="Top" Width="190" FontSize="11" />
                            </Grid>

                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DataTemplate>
    </controls:Pivot.ItemTemplate>
    <controls:Pivot.HeaderTemplate>
        <DataTemplate>
            <TextBlock Text="hiii" TextWrapping="Wrap" FontSize="0" Foreground="White" />
        </DataTemplate>
    </controls:Pivot.HeaderTemplate>
</controls:Pivot>

2 个答案:

答案 0 :(得分:0)

您可以将Pivot控件的标题设置为几乎任何内容,因为它是一个对象。要将其设置为图像而不是默认标题,请将标题设置为“”并在页面的构造函数中执行此操作:

YourPivotControl.Title = new Image { Width = 400, Source = new BitmapImage(new Uri("/someImage.png", UriKind.Relative)) };

答案 1 :(得分:0)

您是否看过visual studio的默认枢轴页面设置?他们完全按照您的意愿行事:

    <!--Pivot Control-->
    <controls:Pivot Title="MY APPLICATION">
        <!--Pivot item one-->
        <controls:PivotItem Header="first">
            <!--Double line list with text wrapping-->
            <ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                      <StackPanel Margin="0,0,0,17" Width="432" Height="78">
                          <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                          <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                      </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </controls:PivotItem>