首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >嵌套ItemsControl取向

嵌套ItemsControl取向
EN

Stack Overflow用户
提问于 2016-08-01 16:41:01
回答 1查看 165关注 0票数 0

我有一个嵌套的ItemsControl。我的数据结构是一个活动的ObservableCollection,它包括一个活动类和一个数据计数的observableCollection (总计、分配、未分配、关闭)。我需要的是:

代码语言:javascript
复制
CAMPAIGN.NAME
     TOTAL     UNASSIGNED     ASSIGNED     CLOSED
CAMPAIGN.NAME
     TOTAL     UNASSIGNED     ASSIGNED     CLOSED

我能够得到第一部分,但由于某些原因,它将不尊重第二个ItemsControl的方向。我遗漏了什么?我的XAML是:

代码语言:javascript
复制
<ItemsControl x:Name="icCampaignChicklets" ItemsSource="{Binding CampChicks}" Grid.Row="1">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid x:Name="gridContent">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <TextBlock x:Name="CampaignHeader" Height="20" Text="{Binding Path=Campaign.Name}" Grid.Row="1"  VerticalAlignment="Top" TextWrapping="Wrap" HorizontalAlignment="Left" />
                    <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10">
                        <ItemsControl x:Name="icChicklets" ItemsSource="{Binding Path=Data}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Border Width="150" Height="140" Background="{Binding Background}" Cursor="Hand"
                                    MouseLeftButtonDown="Chicklet_MouseLeftButtonDown"
                                    >
                                        <Grid x:Name="gridContent" Margin="8,4">
                                            <TextBlock Text="{Binding Caption}" Foreground="White" FontSize="17" />
                                            <TextBlock Text="{Binding CountCaption, Mode=OneWay}" Foreground="White" FontSize="45" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="7" />
                                            <TextBlock Text="Ú" Foreground="#99ffffff" FontSize="30" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="3,5" FontFamily="Wingdings 3" />
                                        </Grid>
                                    </Border>
                                </DataTemplate>

                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-01 17:09:24

如果要更改ItemsControl内容的方向,请将其ItemsPanel属性设置如下:

代码语言:javascript
复制
<ItemsControl
    ...attributes...
    >
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

将其封装在面向水平的父StackPanel中只会横向地安排它和它的兄弟姐妹,但在这种特殊情况下,它没有兄弟姐妹。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38703963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档