从组合框中选择项目时,会生成一些带有组合框灯光消除的元素 - XAML

时间:2015-12-17 09:16:34

标签: c# xaml listview horizontal-scrolling

在其中一个XAML页面上,左侧有3个组合框,右侧有带水平滚动的ListView。

三个组合框不是级联组合框。如果我单击三个组合框中的任何一个,在" PopupRoot"下,会生成一些具有整个屏幕宽度和高度的ComboBoxLightDismiss。这使我的屏幕处于挂起状态,因为这是一些看不见的画布。我无法找出原因。

组合框之前的可视树点击 Visual Tree before Combo box Click

单击组合框或选择任何项目后的可视树 Visual Tree after Combo Box is click or any item is selected

我正在为组合框的左侧User Control添加XAML代码以及下面的页面:

UserControl XAML代码,包含3个组合框

<StackPanel Margin="10,0,0,0">
<TextBlock x:Name="textBlockSourceLabel" Text="Source" Margin="0,6,6,6" Style="{StaticResource LeftNavTextBlock}"/>
<ComboBox Height="30" x:Name="comboBoxSourceName" Margin="0,6,6,6" FontSize="14"
              Style="{StaticResource NewComboBoxStyle}" ItemContainerStyle="{StaticResource NewComboBoxItem}"
              ItemsSource="{Binding Codes,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
              SelectedValue="{Binding SourceFile.FeedCode,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"                  
              Width="250">
    <interactivity:Interaction.Behaviors>
        <awbehaviors:ComboBoxKeyboardSelection/>
        <core:EventTriggerBehavior EventName="SelectionChanged">
            <core:InvokeCommandAction Command="{Binding LoadSelectedSourceCommand}" CommandParameter="{Binding SelectedValue, ElementName=comboBoxSourceName}"/>
        </core:EventTriggerBehavior>
    </interactivity:Interaction.Behaviors>
</ComboBox>

<TextBlock x:Name="textBlockFiscalMonthLabel" Text="Calendar Month" Margin="0,6,6,6" Style="{StaticResource LeftNavTextBlock}" />
<ComboBox Height="30" x:Name="comboBoxFileFiscalMonth" FontSize="14"  Margin="0,6,6,6" Width="250"  ItemsSource="{Binding MonthNames}"   
              DisplayMemberPath="Item1" SelectedValue="{Binding SourceFile.CalendarMonth,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
              SelectedValuePath="Item2" Style="{StaticResource NewComboBoxStyle}" ItemContainerStyle="{StaticResource NewComboBoxItem}">
</ComboBox>

<TextBlock x:Name="textBlockFiscalYearLabel"  Margin="0,6,6,6"  Text="Calendar Year" Style="{StaticResource LeftNavTextBlock}"/>
<ComboBox Height="30" x:Name="comboxBoxFileFiscalYear" Margin="0,6,6,6" FontSize="14"
              ItemsSource="{Binding Years,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
              SelectedValue="{Binding SourceFile.CalendarYear,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
              Style="{StaticResource NewComboBoxStyle}" ItemContainerStyle="{StaticResource NewComboBoxItem}"
              Width="250"></ComboBox>

包含ListView和UserControl的页面的XAML代码

<Grid Style="{StaticResource LayoutRootStyle}" x:Name="gridLayout" VerticalAlignment="Stretch">
<Grid >
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="20*"/>
        <ColumnDefinition Width="80*"/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="0" Background="#FFADB9CA">
        <UserControls:FeedInformation DataContext="{Binding FeedInformationVM}" HorizontalAlignment="Stretch" Margin="0"  Height="{Binding ActualHeight, ElementName=Row1}" Background="{StaticResource gridcontainerBackGroundBrush}"/>
    </Grid>
    <Grid Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="10*"/>
            <RowDefinition Height="90*" x:Name="GridRow"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="50*" x:Name="GridColumn"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="0" HorizontalAlignment="Stretch" x:Name="titleGrid">
            <TextBlock Style="{StaticResource NewHeaderTextStyle}" Text="{Binding FeedSourceFileStatus.FileName}" Margin="10,0,0,0"/>
        </Grid>
        <Grid Grid.Row="1">
            <ListView IsItemClickEnabled="False" IsSwipeEnabled="False" IsDoubleTapEnabled="False" IsTapEnabled="False" SelectionMode="None"
                    Margin="12,25,50,25" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
                    Height="{Binding ActualHeight, ElementName=GridRow}"
                    ItemsSource="{Binding SubItemsCollection, ElementName=pgControl, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    ScrollViewer.HorizontalScrollBarVisibility="Visible"
                    ScrollViewer.HorizontalScrollMode="Enabled"  ScrollViewer.VerticalScrollBarVisibility="Auto" 
                    ItemContainerStyle="{StaticResource LvItemStyle}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ListView  SelectionMode="None" IsZoomedInView="False" IsHoldingEnabled="False" IsSwipeEnabled="False"  x:Name="ListRow" Tag="{Binding RowNo}" 
                                ItemsSource="{Binding FeedData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" 
                                VerticalAlignment="Center" ItemContainerStyle="{StaticResource LvItemStyle}" AllowDrop="True"                
                                ShowsScrollingPlaceholders="True"  CanDragItems="{Binding RowNo, Converter={StaticResource ListInttoBooleanConverter}}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <Grid  Height="35" Width="120" HorizontalAlignment="Center" >
                                        <Rectangle StrokeDashArray="1 1 0.3 1" Height="30" VerticalAlignment="Top" IsHitTestVisible="False"   Opacity="0.5"
                                            Stroke="Gray" StrokeThickness="1" Margin="0" StrokeEndLineCap="Square" StrokeDashOffset="1.5"
                                            Visibility="{Binding Tag, Converter={StaticResource RowNotoVisibilityConverter4}, ElementName=ListRow}" 
                                                Fill="#FF9DC3E6"/>
                                        <TextBlock Text="{Binding FeedCellData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                FontSize="12" LineHeight="13" Foreground="{StaticResource TaxHubItemForegroundBrush}" TextTrimming="WordEllipsis"  Width="120" AllowDrop="True"  Padding="5,1,1,1" TextWrapping="NoWrap" 
                                                VerticalAlignment="Top" Tag="{Binding Tag, ElementName=ListRow}"  ToolTipService.ToolTip="{Binding FeedCellData}"                               
                                                Height="{Binding Tag, Converter={StaticResource RowtoHeightConverter}, RelativeSource={RelativeSource Mode=Self}}" />
                                    </Grid>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                            <ListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <ItemsStackPanel Margin="0,0,0,0" Width="Auto" Orientation="Horizontal" Height="35" VirtualizingStackPanel.VirtualizationMode="Standard"/>
                                </ItemsPanelTemplate>
                            </ListView.ItemsPanel>
                        </ListView>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Standard"/>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>
        </Grid>
    </Grid>
</Grid>

我似乎无法弄清楚在点击组合框时生成此画布的原因。

注意:此应用程序已从Win 8.1 App移至Win 10 UWP应用程序。这似乎在8.1应用程序中正常工作,该应用程序与win 10兼容,但这个问题来自于在UWP中使用

调试之后,我意识到这是因为在外部ListView中使用 VirtualizingStackPanel 。在我的ListView中,每行有200列。当我删除 VirtualizingStackPanel 时,整个列表的水平滚动条没有出现,我无法水平移动。有人可以帮忙解决这个问题吗?

0 个答案:

没有答案