Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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# 水平堆叠面板上列表项之间的间距_C#_Xaml_Windows Phone 8.1 - Fatal编程技术网

C# 水平堆叠面板上列表项之间的间距

C# 水平堆叠面板上列表项之间的间距,c#,xaml,windows-phone-8.1,C#,Xaml,Windows Phone 8.1,如何控制来自投标“速记”的项目之间的空间量?目前,我有空白,这似乎取决于“速记”本身值的大小(因此,如果值为1个字符,则它与下一个值之间的空白比值为2个字符长时更大) 我尝试过在不同的地方将边距和填充设置为零,但都没有效果 <ListView ItemsSource="{Binding Rounds}" IsItemClickEnabled="False" ItemClick="ItemView_ItemClick" ContinuumNavigationTransitionInfo.Ex

如何控制来自投标“速记”的项目之间的空间量?目前,我有空白,这似乎取决于“速记”本身值的大小(因此,如果值为1个字符,则它与下一个值之间的空白比值为2个字符长时更大)

我尝试过在不同的地方将边距和填充设置为零,但都没有效果

<ListView ItemsSource="{Binding Rounds}" IsItemClickEnabled="False" ItemClick="ItemView_ItemClick" ContinuumNavigationTransitionInfo.ExitElementContainer="True">
    <ListView.ItemTemplate>
        <DataTemplate >
            <StackPanel>
                <TextBlock Style="{ThemeResource ListViewItemSubheaderTextBlockStyle}">
                    <Run Text="Round "/>
                    <Run Text="{Binding RoundNumber}" />
                </TextBlock>
                <ListView ItemsSource="{Binding Formations}" >
                    <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Shorthand}"  Style="{ThemeResource ListViewItemTextBlockStyle}" />
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackPanel>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

我不确定
模板中的边距/填充设置在哪里。作为一种解决方法,您可以尝试为您的
ItemContainerStyle设置一个负的
边距

<ListView Name="myList">
     <ListView.ItemContainerStyle>
          <Style TargetType="ListViewItem">
              <Setter Property="Margin" Value="0,0,0,-20" />
          </Style>
     </ListView.ItemContainerStyle>
// rest of the code

//代码的其余部分

列表视图的
ItemView
的第一次出现是内联定义的。因此,当设置
ItemSource
时,
ItemTemplate
将应用于每个项目

ListView.ItemTemplate
包含
绑定速记
。将其放置在
网格中
并将
网格定义为
数据模板的Width=“Auto”或“*”

StackPanel可能有助于更好地定位它。您必须根据所需的显示要求调整栅格DEF

   <DataTemplate>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Column="0" VerticalAlignment="Top" Margin="10,0,0,0">
                <TextBlock Text="{Binding Shorthand}"  Style="{ThemeResource ListViewItemTextBlockStyle}" />
            </StackPanel>
        </Grid>
    </DataTemplate>


并没有完全达到我想要的效果,但确实改善了外观,我将-20改为5,并应用到右边距。@blawford是的,我知道这只是一个解决办法。我很高兴这有点帮助。