(UWP)是否可以减小XAML中特定listview项的宽度

时间:2019-05-24 06:50:31

标签: c# xaml uwp

我有一个列表视图,在窗口底部有水平排列的选项卡。每当调整窗口大小时,选项卡中的任何项目都不应减少以适应窗口宽度。假设我的应用程序处于全屏模式时我有10个选项卡,当我最小化到全屏模式的一半时,我应该有5个选项卡+ 1个其他选项卡(单击后应显示其余5个项目的弹出窗口)。我可以通过切换项目的可见性来部分完成此任务。但是我只是想知道是否有办法将一个listview项目的宽度减小到零?

<Grid  Name="BottomPaneGrid" 
               BorderBrush="#f0f0f0" 
               Background="{x:Bind BottomPaneBackground}"
               BorderThickness="{x:Bind BottomPaneThickness}"
               CornerRadius="{x:Bind BottomPaneCornerRadius}"
               Margin="{x:Bind BottomPaneMargin}"   
               >
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="88"/>
        </Grid.ColumnDefinitions>
        <ListView ItemsSource="{x:Bind test.ModuleTabs}"                 
                  SelectedItem="{x:Bind test.DefaultModuleEnabledTab,Mode=TwoWay}"
                  SelectionChanged="ListViewBottomPaneControl_SelectionChanged"
                  x:Name="ListViewBottomPaneControl"
                  HorizontalAlignment="Center" VerticalAlignment="Stretch">
            <ListView.ItemContainerTransitions>
                <TransitionCollection/>
            </ListView.ItemContainerTransitions>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="HorizontalContentAlignment"  Value="Stretch"/>
                    <Setter Property="VerticalAlignment" Value="Stretch"/>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="Background" Value="Transparent"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <ItemsStackPanel Orientation="Horizontal" />                    
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="entity:Tabs">
                    <StackPanel HorizontalAlignment="Center" Name="TabListingItem"
                                    Visibility="{x:Bind Visibility,Mode=OneWay}">
                            <Image Source="{x:Bind ImagePath,Mode=OneWay}" Opacity="0.8" 
                                           ToolTipService.Placement="Bottom" Height="20" Width="20" Margin="0,0,0,0"/>
                            <TextBlock Text="{x:Bind Tabs,Mode=OneWay}" FontSize="11"
                                               Opacity="0.8" HorizontalAlignment="Center" Margin="0,0,0,0"/>
                        </StackPanel>
                    <!--</Grid>-->
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Button Background="Transparent" x:Name="MoreLink"
                 HorizontalAlignment="Stretch" VerticalAlignment="Stretch"               
                Grid.Column="1" Style="{StaticResource ButtonStyle}"
                Visibility="Collapsed" Flyout="{StaticResource MoreTabsStyle}">
            <StackPanel VerticalAlignment="Center"                                
                            Visibility="Visible">
                <Image Source="/Entities/Assets/morel-1.jpg" Opacity="0.8" 
                           ToolTipService.Placement="Bottom" 
                           ToolTipService.ToolTip="More" Height="20" Width="20"/>
                <TextBlock Text="More" FontSize="11"
                               Opacity="0.8" HorizontalAlignment="Center"/>
            </StackPanel>
        <Button>
    </Grid>

0 个答案:

没有答案