如何从ListBox中从C#中调整项的大小?我可以做ListBox.Height = 100;,但是我不知道如何在ListBox中调整条目的大小。帮帮我求你了。
我需要使用listBox方法更改ManipulationDelta中项目的大小及其编号。
主要xaml代码:
<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.发布于 2014-07-07 18:56:24
始终可以在Xaml页面中更改ListBox的ListBox。
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Height="200" Width="200" /> //This is just an example you can use any control
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>希望这是你想要的。
发布于 2014-07-07 18:52:28
您需要访问列表框中的项并为它们设置个人高度,
foreach (ListBoxItem lv in YourListbox.Items)
{
lv.Height = 10;
}https://stackoverflow.com/questions/24617692
复制相似问题