• 选中DataGrid的Cell而不是row


    主要是针对DataGridCellsPresenter而不是SelectiveScrollingGrid,使用时DataGridRow应用这个style就可以了。
    

    <Style x:Key="grdStudyListDataGridRowStyle" TargetType="{x:Type DataGridRow}">
                    <Setter Property="SnapsToDevicePixels" Value="true"/>
                    <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
                    <Setter Property="ValidationErrorTemplate">
                        <Setter.Value>
                            <ControlTemplate>
                                <TextBlock Foreground="Red" Margin="2,0,0,0" Text="!" VerticalAlignment="Center"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type DataGridRow}">
                                <Grid x:Name="DGR_Border" Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Width="Auto">
                                    <SelectiveScrollingGrid x:Name="selectiveScrollingGrid" d:LayoutOverrides="Width">
                                        <SelectiveScrollingGrid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="*"/>
                                        </SelectiveScrollingGrid.ColumnDefinitions>
                                        <SelectiveScrollingGrid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="Auto"/>
                                        </SelectiveScrollingGrid.RowDefinitions>
                                        <Border x:Name="bdCell"  Grid.Column="1" HorizontalAlignment="Left">
                                            <DataGridCellsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
                                        </Border>
                                        <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1" SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" Visibility="{TemplateBinding DetailsVisibility}"/>
                                        <DataGridRowHeader Grid.RowSpan="2" SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" Visibility="Collapsed"/>
                                    </SelectiveScrollingGrid>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                                        <Setter Property="Background" TargetName="bdCell" Value="{DynamicResource Brush_PA_CSW_DataGridItemDefaultHighlight}"/>
                                    </DataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding (FrameworkElement.DataContext).CurrentDeletingLevel, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Value="Study"/>
    
                                            <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Background" TargetName="bdCell" Value="{DynamicResource Brush_PA_CSW_DataGridItemHighlight}"/>
                                    </MultiDataTrigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Background" Value="Transparent"/>
                </Style>
    
  • 相关阅读:
    正常安装selenium后,pycharm导入selenium失败
    python+selenium自动化的准备 2:安装python 3.7.4 和selenium 2.53.1
    python+selenium自动化的准备 1:安装浏览器(火狐)及浏览器插件firebug与firepath、selenium IDE
    虚拟机安装win10系统
    官网下载Windows 10 系统的iso镜像文件
    电脑系统属性中用户与系统环境变量的区别
    验证器
    EchoMode的显示效果
    文本框类控件
    QLabel标签快捷键的使用
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3169439.html
Copyright © 2020-2023  润新知