在listview问题中扩展

时间:2016-12-05 20:18:55

标签: xaml listview

我是新来的,我需要帮助。

enter image description here

我对PJ中的屏幕显示有一些问题。我想通过鼠标飞行子菜单列车线时删除蓝色,但我不能。有人可以帮我吗? 请附上截图,了解他的样子和属于它的XAML代码。

<UserControl.Resources>
    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

    <Style x:Key="MenuMaterialDesignExpanderHeaderToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Margin" Value="16,0,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ContentPresenter VerticalAlignment="Center" Content="{TemplateBinding Content}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MenuMaterialDesignExpander" TargetType="{x:Type Expander}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
        <Setter Property="TextBlock.FontWeight" Value="DemiBold" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ExpansionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0" To="Expanded">
                                        <VisualTransition.GeneratedEasingFunction>
                                            <CubicEase EasingMode="EaseOut" />
                                        </VisualTransition.GeneratedEasingFunction>
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                                <EasingDoubleKeyFrame KeyTime="0" Value=".5" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                    <VisualTransition GeneratedDuration="0" To="Collapsed">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.5" Value="{x:Static Visibility.Collapsed}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value=".5" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                                <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Expanded">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Collapsed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Opacity">
                                            <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value=".5" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0"
                                                         Storyboard.TargetName="NormalToggleButton"
                                                         Storyboard.TargetProperty="Opacity"
                                                         To=".25" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.RowDefinitions>
                            <RowDefinition MinHeight="25" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border BorderThickness="0">
                            <Grid>
                                <ToggleButton x:Name="NormalToggleButton"
                                              Grid.Column="1"
                                              IsChecked="{Binding Path=IsExpanded,
                                                                  Mode=TwoWay,
                                                                  RelativeSource={RelativeSource TemplatedParent}}"
                                              Style="{StaticResource MenuMaterialDesignExpanderHeaderToggleButton}">
                                    <ContentPresenter HorizontalAlignment="Stretch"
                                                      VerticalAlignment="Center"
                                                      ContentSource="Header"
                                                      RecognizesAccessKey="True" />
                                </ToggleButton>
                            </Grid>
                        </Border>
                        <Border Grid.Row="1">
                            <ContentPresenter Name="PART_Content" RenderTransformOrigin="0,0">
                                <ContentPresenter.LayoutTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="0.5" ScaleY="0" />
                                        <SkewTransform />
                                        <RotateTransform />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </ContentPresenter.LayoutTransform>
                            </ContentPresenter>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>
<Grid Width="300">
    <StackPanel Grid.Row="0"
                Margin="5"
                Orientation="Vertical">

        <!--  DatabaseSelection  -->
        <Button Margin="2"
                HorizontalContentAlignment="Stretch"
                Command="{Binding AddDatabaseSelectionTabItemCommand}"
                ToolTip="{Binding ActivatedDatabaseTitleTooltip}">
            <Button.CommandParameter>
                <params:TabItemInfo Title="{lex:Loc DatabaseSelection}"
                                    PackIcon="Database"
                                    RegionName="DatabaseSelectionRegion"
                                    Type="Unique" />
            </Button.CommandParameter>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <materialDesign:PackIcon Grid.Column="0"
                                         Width="22"
                                         Height="22"
                                         Margin="0,0,5,0"
                                         Kind="Database" />
                <TextBlock Grid.Column="1"
                           VerticalAlignment="Center"
                           FontSize="14"
                           FontWeight="Bold"
                           Text="{Binding ActivatedDatabaseType}" />
                <TextBlock Grid.Column="2"
                           VerticalAlignment="Center"
                           FontSize="14"
                           Text=" - " />
                <TextBlock Grid.Column="3"
                           VerticalAlignment="Center"
                           FontSize="14"
                           Text="{Binding ActivatedDatabaseTitle}" />
            </Grid>
        </Button>

        <!--  Explorateur d'éléments  -->
        <Button Margin="2"
                HorizontalContentAlignment="Left"
                Command="{Binding AddTabItemCommand}"
                Style="{StaticResource MaterialDesignFlatButton}">
            <Button.CommandParameter>
                <params:TabItemInfo Title="{lex:Loc ItemsExplorer}"
                                    RegionName="ItemsExplorerRegion"
                                    PackIcon="Sitemap"
                                    Type="Unique" />
            </Button.CommandParameter>
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Width="22"
                                         Height="22"
                                         Margin="0,0,5,0"
                                         Kind="Sitemap" />
                <TextBlock VerticalAlignment="Center"
                           FontSize="14"
                           Text="{lex:Loc ItemsExplorer}" />
            </StackPanel>
        </Button>

        <!--  Schéma principe  -->
        <ListView Margin="10,0,0,4"
                  Background="Transparent"
                  BorderThickness="0"
                  ItemsSource="{Binding RelecturesCollection}"
                  ScrollViewer.HorizontalScrollBarVisibility="Hidden">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Button HorizontalContentAlignment="Left"
                            Command="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                             AncestorType={x:Type local:MenuView}},
                                              Path=DataContext.AddTabItemCommand,
                                              Mode=OneTime}"
                            CommandParameter="{Binding TabItemInfo}"
                            Style="{StaticResource MaterialDesignFlatButton}">
                        <Grid Width="250">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0"
                                       VerticalAlignment="Center"
                                       FontSize="14"
                                       FontWeight="Bold"
                                       Foreground="{Binding TypeSchematique.Color}"
                                       Text="{Binding TypeSchematique.Nom}" />
                            <TextBlock Grid.Column="1"
                                       Margin="3,0"
                                       VerticalAlignment="Center"
                                       FontSize="14"
                                       FontWeight="Normal"
                                       Text="-" />
                            <TextBlock Grid.Column="2"
                                       VerticalAlignment="Center"
                                       FontSize="14"
                                       FontWeight="Normal"
                                       Text="{Binding Nom}"
                                       TextTrimming="CharacterEllipsis"
                                       ToolTip="{Binding Nom}" />
                            <TextBlock Grid.Column="3"
                                       Margin="3,0,0,0"
                                       VerticalAlignment="Center"
                                       FontSize="14"
                                       FontStyle="Italic"
                                       FontWeight="Normal"
                                       Text="{Binding Version}" />
                        </Grid>
                    </Button>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <!--  Outils  -->
        <Expander Margin="0,4"
                  HorizontalAlignment="Stretch"
                  IsEnabled="{Binding IsDatabaseActivated}"
                  IsExpanded="True"
                  Style="{StaticResource MenuMaterialDesignExpander}">
            <Expander.Header>
                <StackPanel Cursor="Hand" Orientation="Horizontal">
                    <materialDesign:PackIcon Width="22"
                                             Height="22"
                                             Margin="0,0,5,0"
                                             Kind="Wrench" />
                    <TextBlock VerticalAlignment="Center"
                               FontSize="14"
                               Text="{lex:Loc Tools}" />
                </StackPanel>
            </Expander.Header>
            <ListView Margin="10,0,0,0"
                      Background="Transparent"
                      BorderThickness="0">
                <ListViewItem>
                    <Button HorizontalContentAlignment="Left"
                            Command="{Binding AddTabItemCommand}"
                            Style="{StaticResource MaterialDesignFlatButton}">
                        <Button.CommandParameter>
                            <params:TabItemInfo Title="{lex:Loc Components}"
                                                RegionName="ComponentLibraryImportRegion"
                                    PackIcon="Import"
                                                Type="Unique" />
                        </Button.CommandParameter>
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Width="22"
                                                     Height="22"
                                                     Margin="0,0,5,0"
                                                     Kind="Import" />
                            <TextBlock VerticalAlignment="Center"
                                       FontSize="14"
                                       Text="{lex:Loc Components}" />
                        </StackPanel>
                    </Button>
                </ListViewItem>
                <ListViewItem>
                    <Button HorizontalContentAlignment="Left"
                            Command="{Binding AddTabItemCommand}"
                            Style="{StaticResource MaterialDesignFlatButton}">
                        <Button.CommandParameter>
                            <params:TabItemInfo Title="{lex:Loc Associations}"
                                                RegionName="ComponentLibraryAssociationRegion"
                                    PackIcon="AutoFix"
                                                Type="Unique" />
                        </Button.CommandParameter>
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Width="22"
                                                     Height="22"
                                                     Margin="0,0,5,0"
                                                     Kind="AutoFix" />
                            <TextBlock VerticalAlignment="Center"
                                       FontSize="14"
                                       Text="{lex:Loc Associations}" />
                        </StackPanel>
                    </Button>
                </ListViewItem>
                <!--Creer un sous menu dans la View "Trains Vues"-->
                <Expander Margin="0,4"
                          HorizontalAlignment="Stretch"
                          IsExpanded="True"
                  Style="{StaticResource MenuMaterialDesignExpander}">
                    <Expander.Header>
                        <StackPanel Cursor="Hand" Orientation="Horizontal" >
                            <materialDesign:PackIcon Width="22"
                                             Height="22"
                                             Margin="0,0,5,0"
                                             Kind="Eye" />
                            <TextBlock VerticalAlignment="Center"
                                       FontSize="14"
                                       Text="{lex:Loc TrainsViews}" />
                        </StackPanel>
                    </Expander.Header>
                    <ListView Margin="10,0,0,0"
                              Background="Transparent"
                              BorderThickness="0">
                        <!--Sous Sous Menu Lignes Trains-->
                        <ListViewItem>
                            <Button HorizontalContentAlignment="Left"
                                    Command="{Binding AddTabItemCommand}"
                                    Style="{StaticResource MaterialDesignFlatButton}">
                                <Button.CommandParameter>
                                    <params:TabItemInfo Title="{lex:Loc TrainsLines}"
                                                        RegionName="ComponentLibraryTrainLinesRegion"
                                                        PackIcon="Train"
                                                        Type="Unique" />
                                </Button.CommandParameter>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Width="22"
                                                             Height="22"
                                                             Margin="0,0,5,0"
                                                             Kind="Train" />
                                    <TextBlock VerticalAlignment="Center"
                                           FontSize="14"
                                           Text="{lex:Loc Trainslines}" />
                                </StackPanel>
                            </Button>
                        </ListViewItem>
                        <!--Sous Sous Menu Options/Variantes-->
                        <ListViewItem>
                            <Button HorizontalContentAlignment="Left"
                                Command="{Binding AddTabItemCommand}"
                                Style="{StaticResource MaterialDesignFlatButton}">
                                <Button.CommandParameter>
                                    <params:TabItemInfo Title="{lex:Loc OptionsVersions}"
                                                        RegionName="OptionsVersionsRegion"
                                                        PackIcon="Check"
                                                        Type="Unique" />
                                </Button.CommandParameter>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Width="22"
                                                             Height="22"
                                                             Margin="0,0,5,0"
                                                             Kind="Check" />
                                    <TextBlock VerticalAlignment="Center"
                                               FontSize="14"
                                               Text="{lex:Loc OptionsVersions}" />
                                </StackPanel>
                            </Button>
                        </ListViewItem>
                    </ListView>
                </Expander>
            </ListView>
        </Expander>


        <ListView Margin="10,0,0,4"
                  Background="Transparent"
                  BorderThickness="0"
                  ItemsSource="{Binding CoherenceCollection}"
                  ScrollViewer.HorizontalScrollBarVisibility="Hidden">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Button HorizontalContentAlignment="Left"
                            Command="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                             AncestorType={x:Type local:MenuView}},
                                              Path=DataContext.AddTabItemCommand,
                                              Mode=OneTime}"
                            CommandParameter="{Binding TabItemInfo}"
                            Style="{StaticResource MaterialDesignFlatButton}">
                        <Grid Width="250">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0"
                                       VerticalAlignment="Center"
                                       FontSize="14"
                                       FontWeight="Bold"
                                       Text="{Binding Nom}" />
                        </Grid>
                    </Button>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>
</Grid>

0 个答案:

没有答案