列表框项windows phone 8

本文关键字:phone windows 列表 | 更新日期: 2023-09-27 18:12:02

如何从c#中调整列表框中的项目大小?我可以做ListBox.Height = 100;,但我不知道如何调整列表框中的项目大小。请帮帮我。

我需要使用ManipulationDelta方法更改listBox中项目的大小和它们的数量。

主代码:

<ListBox x:Name="tileList"
        Grid.Row="0"
        Margin="5"
        ManipulationCompleted="tileList_ManipulationCompleted"
        ManipulationDelta="tileList_ManipulationDelta">
    <ListBox.RenderTransform>
        <CompositeTransform/>
    </ListBox.RenderTransform>
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <toolkit:WrapPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <toolkit:HubTile x:Name="hubMain"
                            Title="{Binding Title}"
                            Margin="3"
                            DisplayNotification="{Binding DisplayNotification}"
                            GroupTag="{Binding GroupTag}"
                            Message="{Binding Message}"
                            Notification="{Binding Notification}"
                            Size="Medium"
                            Source="{Binding ImageUri}" />
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
and C# code:
private void tileList_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    if (e.PinchManipulation != null)
    {
        double newWidth = 0.0, newHieght = 0.0;
        foreach (tileList lv in tileList.Items)
        {
            lv.Height = 10;
        }
    }
}
private void tileList_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
    m_Zoom = 200 / 10;
}
Thanks.

列表框项windows phone 8

你可以在Xaml页面中更改ListBox的ItemTemplate

<ListBox>
   <ListBox.ItemTemplate>
      <DataTemplate>
         <TextBlock Height="200" Width="200" /> //This is just an example you can use any control
      </DataTemplate>
   </ListBox.ItemTemplate>
</ListBox>

希望这是你想要的

你需要访问列表框的项目,并为他们设置单独的高度,像这样,

 foreach (ListBoxItem lv in YourListbox.Items)
        {
            lv.Height = 10;
        }